Below the analysis corresponding to the paper “Telomere attrition rates are associated with weather conditions and predict productive lifespan in dairy cattle” by Seeker et al. 2021 (Scientific Reports) can be found.
library(ggplot2)
library(nlme)
library(lme4)
## Loading required package: Matrix
##
## Attaching package: 'lme4'
## The following object is masked from 'package:nlme':
##
## lmList
library(lmerTest)
##
## Attaching package: 'lmerTest'
## The following object is masked from 'package:lme4':
##
## lmer
## The following object is masked from 'package:stats':
##
## step
library(grid)
library(gridExtra)
library(mgcv) # for GAM
## This is mgcv 1.8-34. For overview type 'help("mgcv-package")'.
library(data.table)
library(stringr)
#library(magrittr)
library(ggthemes)
library(plyr)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:plyr':
##
## arrange, count, desc, failwith, id, mutate, rename, summarise,
## summarize
## The following objects are masked from 'package:data.table':
##
## between, first, last
## The following object is masked from 'package:gridExtra':
##
## combine
## The following object is masked from 'package:nlme':
##
## collapse
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(survival)
library(survminer)
## Loading required package: ggpubr
## Registered S3 methods overwritten by 'car':
## method from
## influence.merMod lme4
## cooks.distance.influence.merMod lme4
## dfbeta.influence.merMod lme4
## dfbetas.influence.merMod lme4
##
## Attaching package: 'ggpubr'
## The following object is masked from 'package:plyr':
##
## mutate
library(ggsci) # for colours
library(here) # for reproducible file paths
## here() starts at /Users/lseeker/Documents/Work/cattle_telomeres/TelomereChangeInDairyCattle
##
## Attaching package: 'here'
## The following object is masked from 'package:plyr':
##
## here
# Make colour palette
mypal <- pal_npg("nrc", alpha = 0.7)(10)
mypal2 <-pal_tron("legacy", alpha = 0.7)(7)
mypal3<-pal_lancet("lanonc", alpha = 0.7)(9)
mypal4<-pal_simpsons(palette = c("springfield"), alpha = 0.7)(16)
mycoloursP<- c(mypal, mypal2, mypal3, mypal4)
data <- read.csv(here::here("data", "LongTelomereDataCattle.csv"))
mean_year_change <- data.frame(mean_change_rate =
tapply(as.numeric(paste(data$atrr_rate_per_year)),
data$recoded_id, mean, na.rm = TRUE))
## Warning in tapply(as.numeric(paste(data$atrr_rate_per_year)), data$recoded_id, :
## NAs introduced by coercion
mean_year_change$recoded_id <- rownames(mean_year_change)
data <- merge(data, mean_year_change, by = "recoded_id")
mes_er<- ggplot(data, aes(x = as.numeric(paste(residual_rltl_tminus1)),
y = mean_change_rate,
colour = AgeGroup)) +
geom_point(size = 0.2)+
scale_color_manual(values=mycoloursP[16:40]) +
theme_classic() +
geom_abline(intercept = 0, slope = 0, colour = "red") +
stat_smooth(method = lm, formula = y ~ x) +
ylab("Mean yearly rate in RLTL change")+
xlab("Baseline RLTL")
mes_er
## Warning in FUN(X[[i]], ...): NAs introduced by coercion
## Warning in FUN(X[[i]], ...): NAs introduced by coercion
## Warning in FUN(X[[i]], ...): NAs introduced by coercion
## Warning: Removed 305 rows containing non-finite values (stat_smooth).
## Warning: Removed 305 rows containing missing values (geom_point).
cor.test(as.numeric(paste(data$residual_rltl_tminus1)), data$mean_change_rate)
## Warning in cor.test(as.numeric(paste(data$residual_rltl_tminus1)),
## data$mean_change_rate): NAs introduced by coercion
##
## Pearson's product-moment correlation
##
## data: as.numeric(paste(data$residual_rltl_tminus1)) and data$mean_change_rate
## t = -2.2644, df = 1018, p-value = 0.02376
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.131603730 -0.009452614
## sample estimates:
## cor
## -0.07079357
Weather data was downloaded from the metoffice homepage from the station in Eskdalemuir which is the closest accessible weather data station to Dumfries (21.8 miles or 35.1 km based on freemaptools
Text data was importet to Excel, where season and year summary statistics were added. Then the data was exported as .csv file.
“sample_year” in the weather data was coded so that it included the first three month of the calendar year in which samples were taken plus the last nine month of the previous calendar year. So the most recent data was collected in the first quartal (Q1) while Q4, Q3, Q2 go back in time in that order. This is done in this way, because samples are usually taken in March and therefore it makes most sense that a sampling year goes from April to March.
weather<-read.csv(here::here("data", "eskdalemuirdata_red_sampleYear.csv"))
data <- merge(data, weather, by = "sample_year" )
To keep this document cleaner “createInputData.Rmd” was used to create different input dataframes in the format required for different analyses (for example a Cox- proportional hazard model needs different infromation to a linear mixed model).
# create data which only lists each animal ID once (needed for some counts/ histograms below)
uData <- data[!duplicated(data$recoded_id), ]
# create data that excludes all first measurements without t-1 time point. This is used for investigations of change
redData <- subset(data, data$residual_rltl_tminus1 != "NULL")
init_change_dat <- read.csv(here::here("data", "first_year_long_tel_cattle.csv"))
coxData <- read.csv(here::here("data", "cox_data.csv"))
coxDataR <- subset(coxData, coxData$amp_305_lactation != "NULL")
deadD <- subset(data, data$herd_life != "NULL")
redDeadD <- subset(redData, redData$herd_life != "NULL")
uDeadData <- redDeadD[!duplicated(redDeadD$recoded_id), ]
# Data for repeating Cox proportional hazard model without without the fist measurement.
red_data_l_new <- read.csv(here::here("data", "excluded_less_3_month.csv"))
uniq_red_data_l_new <- red_data_l_new[!duplicated(red_data_l_new$recoded_id), ]
# df with more than two measurements
more_2 <- read.csv(here::here("data", "more_2_sampl.csv"))
u_more_2 <- more_2[!duplicated(more_2$recoded_id), ]
cor.test(redData$residual_rltl_t, as.numeric(paste(redData$residual_rltl_tminus1)))
##
## Pearson's product-moment correlation
##
## data: redData$residual_rltl_t and as.numeric(paste(redData$residual_rltl_tminus1))
## t = 13.058, df = 1018, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## 0.3249385 0.4301473
## sample estimates:
## cor
## 0.3787659
SubsPlot <- ggplot(redData, aes(x = as.numeric(paste(residual_rltl_tminus1)), y = redData$residual_rltl_t)) +
geom_point() +
xlab("RLTL at time t-1") +
ylab("RLTL at time t") +
theme_classic(20) +
geom_abline(intercept = 0, slope = 1, colour = "red") +
stat_smooth(method = lm, formula = y ~ x) #+ annotate("text", x = -0.4, y = 0.5, label = "(B)", fontface =2, size = 10)
agePlot <- ggplot(redData, aes(x = as.factor(redData$age_y), y = as.numeric(paste(redData$diff_rltl_res)), colour = as.factor(redData$age_y))) +
geom_jitter() +
theme_classic(20) +
xlab("Age in years") +
ylab("RLTL change") +
geom_boxplot() +
scale_color_manual(values = mycoloursP[16:40]) +
theme(legend.position = "none") #+ annotate("text", x = 1, y = 0.5, label = "(A)", fontface =2, size = 10)
grid.arrange(agePlot, SubsPlot, ncol = 2)
## Warning: Use of `redData$age_y` is discouraged. Use `age_y` instead.
## Warning: Use of `redData$diff_rltl_res` is discouraged. Use `diff_rltl_res`
## instead.
## Warning: Use of `redData$age_y` is discouraged. Use `age_y` instead.
## Warning: Use of `redData$age_y` is discouraged. Use `age_y` instead.
## Warning: Use of `redData$diff_rltl_res` is discouraged. Use `diff_rltl_res`
## instead.
## Warning: Use of `redData$age_y` is discouraged. Use `age_y` instead.
## Warning: Use of `redData$residual_rltl_t` is discouraged. Use `residual_rltl_t`
## instead.
## Warning: Use of `redData$residual_rltl_t` is discouraged. Use `residual_rltl_t`
## instead.
cor.test(redData$residual_rltl_t, as.numeric(paste(redData$residual_rltl_tminus1)))
##
## Pearson's product-moment correlation
##
## data: redData$residual_rltl_t and as.numeric(paste(redData$residual_rltl_tminus1))
## t = 13.058, df = 1018, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## 0.3249385 0.4301473
## sample estimates:
## cor
## 0.3787659
## Call: survfit(formula = Surv(init_change_dat$TimeMeasure, init_change_dat$Event ==
## 1) ~ init_change_dat$ResDiff_3G)
##
## init_change_dat$ResDiff_3G=1
## time n.risk n.event survival std.err lower 95% CI upper 95% CI
## 330 97 1 0.9897 0.0103 0.9698 1.000
## 349 96 1 0.9794 0.0144 0.9515 1.000
## 476 95 1 0.9691 0.0176 0.9352 1.000
## 499 94 2 0.9485 0.0225 0.9055 0.993
## 535 92 1 0.9381 0.0245 0.8914 0.987
## 544 91 1 0.9278 0.0263 0.8777 0.981
## 658 90 1 0.9175 0.0279 0.8644 0.974
## 699 89 1 0.9072 0.0295 0.8513 0.967
## 724 88 1 0.8969 0.0309 0.8384 0.960
## 731 87 1 0.8866 0.0322 0.8257 0.952
## 742 86 1 0.8763 0.0334 0.8132 0.944
## 750 85 1 0.8660 0.0346 0.8008 0.936
## 759 84 1 0.8557 0.0357 0.7885 0.929
## 760 83 1 0.8454 0.0367 0.7764 0.920
## 803 82 1 0.8351 0.0377 0.7644 0.912
## 845 81 1 0.8247 0.0386 0.7524 0.904
## 888 80 1 0.8144 0.0395 0.7406 0.896
## 906 79 1 0.8041 0.0403 0.7289 0.887
## 923 78 1 0.7938 0.0411 0.7173 0.879
## 925 77 1 0.7835 0.0418 0.7057 0.870
## 944 76 1 0.7732 0.0425 0.6942 0.861
## 948 75 1 0.7629 0.0432 0.6828 0.852
## 958 74 1 0.7526 0.0438 0.6714 0.844
## 961 73 1 0.7423 0.0444 0.6601 0.835
## 1019 72 1 0.7320 0.0450 0.6489 0.826
## 1045 71 1 0.7216 0.0455 0.6377 0.817
## 1110 70 1 0.7113 0.0460 0.6266 0.807
## 1127 69 1 0.7010 0.0465 0.6156 0.798
## 1156 68 1 0.6907 0.0469 0.6046 0.789
## 1177 67 1 0.6804 0.0473 0.5937 0.780
## 1195 66 1 0.6701 0.0477 0.5828 0.771
## 1205 65 1 0.6598 0.0481 0.5719 0.761
## 1283 64 1 0.6495 0.0484 0.5611 0.752
## 1301 63 1 0.6392 0.0488 0.5504 0.742
## 1345 62 1 0.6289 0.0491 0.5397 0.733
## 1364 61 1 0.6186 0.0493 0.5291 0.723
## 1371 60 1 0.6082 0.0496 0.5185 0.714
## 1384 59 1 0.5979 0.0498 0.5079 0.704
## 1417 58 1 0.5876 0.0500 0.4974 0.694
## 1436 57 1 0.5773 0.0502 0.4869 0.684
## 1483 56 1 0.5670 0.0503 0.4765 0.675
## 1567 55 1 0.5567 0.0504 0.4661 0.665
## 1575 54 1 0.5464 0.0505 0.4558 0.655
## 1588 53 1 0.5361 0.0506 0.4455 0.645
## 1608 52 1 0.5258 0.0507 0.4352 0.635
## 1615 51 1 0.5155 0.0507 0.4250 0.625
## 1661 50 1 0.5052 0.0508 0.4148 0.615
## 1715 49 1 0.4948 0.0508 0.4047 0.605
## 1739 48 1 0.4845 0.0507 0.3946 0.595
## 1756 47 1 0.4742 0.0507 0.3846 0.585
## 1758 46 1 0.4639 0.0506 0.3746 0.575
## 1762 45 1 0.4536 0.0505 0.3646 0.564
## 1766 44 2 0.4330 0.0503 0.3448 0.544
## 1786 42 1 0.4227 0.0502 0.3350 0.533
## 1822 41 1 0.4124 0.0500 0.3252 0.523
## 1855 40 1 0.4021 0.0498 0.3154 0.512
## 1937 39 1 0.3918 0.0496 0.3057 0.502
## 1940 38 1 0.3814 0.0493 0.2961 0.491
## 1942 37 1 0.3711 0.0491 0.2864 0.481
## 1977 36 1 0.3608 0.0488 0.2769 0.470
## 1999 35 1 0.3505 0.0484 0.2673 0.460
## 2001 34 1 0.3402 0.0481 0.2579 0.449
## 2018 33 1 0.3299 0.0477 0.2484 0.438
## 2035 30 1 0.3189 0.0474 0.2383 0.427
## 2041 29 1 0.3079 0.0470 0.2283 0.415
## 2060 28 1 0.2969 0.0466 0.2183 0.404
## 2067 27 2 0.2749 0.0457 0.1985 0.381
## 2072 25 1 0.2639 0.0452 0.1887 0.369
## 2075 24 1 0.2529 0.0446 0.1790 0.357
## 2086 23 1 0.2419 0.0440 0.1694 0.346
## 2113 20 1 0.2298 0.0434 0.1587 0.333
## 2166 17 1 0.2163 0.0429 0.1466 0.319
## 2185 16 1 0.2028 0.0423 0.1347 0.305
## 2191 15 1 0.1893 0.0416 0.1230 0.291
## 2235 13 1 0.1747 0.0409 0.1105 0.276
## 2264 12 1 0.1602 0.0400 0.0982 0.261
## 2285 10 1 0.1441 0.0390 0.0848 0.245
## 2325 8 1 0.1261 0.0381 0.0698 0.228
## 2457 7 1 0.1081 0.0367 0.0556 0.210
## 2583 4 1 0.0811 0.0361 0.0339 0.194
##
## init_change_dat$ResDiff_3G=2
## time n.risk n.event survival std.err lower 95% CI upper 95% CI
## 383 97 1 0.9897 0.0103 0.9698 1.000
## 501 96 1 0.9794 0.0144 0.9515 1.000
## 628 95 1 0.9691 0.0176 0.9352 1.000
## 636 94 1 0.9588 0.0202 0.9200 0.999
## 658 93 1 0.9485 0.0225 0.9055 0.993
## 749 92 1 0.9381 0.0245 0.8914 0.987
## 775 91 1 0.9278 0.0263 0.8777 0.981
## 805 90 1 0.9175 0.0279 0.8644 0.974
## 822 89 1 0.9072 0.0295 0.8513 0.967
## 830 88 1 0.8969 0.0309 0.8384 0.960
## 840 87 1 0.8866 0.0322 0.8257 0.952
## 867 86 1 0.8763 0.0334 0.8132 0.944
## 908 85 1 0.8660 0.0346 0.8008 0.936
## 909 84 1 0.8557 0.0357 0.7885 0.929
## 919 83 1 0.8454 0.0367 0.7764 0.920
## 923 82 1 0.8351 0.0377 0.7644 0.912
## 928 81 1 0.8247 0.0386 0.7524 0.904
## 982 80 1 0.8144 0.0395 0.7406 0.896
## 995 79 1 0.8041 0.0403 0.7289 0.887
## 1006 78 1 0.7938 0.0411 0.7173 0.879
## 1033 77 1 0.7835 0.0418 0.7057 0.870
## 1082 76 1 0.7732 0.0425 0.6942 0.861
## 1094 75 1 0.7629 0.0432 0.6828 0.852
## 1137 74 1 0.7526 0.0438 0.6714 0.844
## 1160 73 1 0.7423 0.0444 0.6601 0.835
## 1182 72 1 0.7320 0.0450 0.6489 0.826
## 1193 71 1 0.7216 0.0455 0.6377 0.817
## 1263 70 1 0.7113 0.0460 0.6266 0.807
## 1341 69 1 0.7010 0.0465 0.6156 0.798
## 1373 68 1 0.6907 0.0469 0.6046 0.789
## 1378 67 1 0.6804 0.0473 0.5937 0.780
## 1461 66 1 0.6701 0.0477 0.5828 0.771
## 1515 65 1 0.6598 0.0481 0.5719 0.761
## 1516 64 1 0.6495 0.0484 0.5611 0.752
## 1532 63 1 0.6392 0.0488 0.5504 0.742
## 1557 62 1 0.6289 0.0491 0.5397 0.733
## 1561 61 1 0.6186 0.0493 0.5291 0.723
## 1565 60 1 0.6082 0.0496 0.5185 0.714
## 1596 59 1 0.5979 0.0498 0.5079 0.704
## 1604 58 1 0.5876 0.0500 0.4974 0.694
## 1610 57 1 0.5773 0.0502 0.4869 0.684
## 1624 56 1 0.5670 0.0503 0.4765 0.675
## 1627 55 1 0.5567 0.0504 0.4661 0.665
## 1633 54 1 0.5464 0.0505 0.4558 0.655
## 1638 53 1 0.5361 0.0506 0.4455 0.645
## 1657 52 1 0.5258 0.0507 0.4352 0.635
## 1693 51 1 0.5155 0.0507 0.4250 0.625
## 1715 50 1 0.5052 0.0508 0.4148 0.615
## 1750 49 1 0.4948 0.0508 0.4047 0.605
## 1786 48 1 0.4845 0.0507 0.3946 0.595
## 1793 47 1 0.4742 0.0507 0.3846 0.585
## 1815 46 1 0.4639 0.0506 0.3746 0.575
## 1825 45 1 0.4536 0.0505 0.3646 0.564
## 1830 44 1 0.4433 0.0504 0.3547 0.554
## 1848 43 1 0.4330 0.0503 0.3448 0.544
## 1855 42 2 0.4124 0.0500 0.3252 0.523
## 1903 40 1 0.4021 0.0498 0.3154 0.512
## 1904 39 1 0.3918 0.0496 0.3057 0.502
## 1927 38 1 0.3814 0.0493 0.2961 0.491
## 1960 37 1 0.3711 0.0491 0.2864 0.481
## 1992 35 1 0.3605 0.0488 0.2765 0.470
## 2015 32 1 0.3493 0.0485 0.2660 0.459
## 2045 31 1 0.3380 0.0483 0.2555 0.447
## 2079 29 1 0.3263 0.0480 0.2446 0.435
## 2192 24 1 0.3127 0.0479 0.2317 0.422
## 2275 21 2 0.2830 0.0477 0.2033 0.394
## 2375 15 1 0.2641 0.0481 0.1848 0.377
## 2452 11 1 0.2401 0.0494 0.1604 0.359
## 2486 9 1 0.2134 0.0506 0.1341 0.340
## 2623 7 1 0.1829 0.0517 0.1051 0.318
## 2766 4 1 0.1372 0.0554 0.0621 0.303
## 2767 3 1 0.0915 0.0525 0.0297 0.282
##
## init_change_dat$ResDiff_3G=3
## time n.risk n.event survival std.err lower 95% CI upper 95% CI
## 302 97 1 0.990 0.0103 0.9698 1.000
## 495 96 1 0.979 0.0144 0.9515 1.000
## 641 95 1 0.969 0.0176 0.9352 1.000
## 648 94 1 0.959 0.0202 0.9200 0.999
## 721 93 1 0.948 0.0225 0.9055 0.993
## 727 92 1 0.938 0.0245 0.8914 0.987
## 735 91 1 0.928 0.0263 0.8777 0.981
## 798 90 1 0.918 0.0279 0.8644 0.974
## 833 89 1 0.907 0.0295 0.8513 0.967
## 895 88 1 0.897 0.0309 0.8384 0.960
## 897 87 1 0.887 0.0322 0.8257 0.952
## 904 86 1 0.876 0.0334 0.8132 0.944
## 930 85 1 0.866 0.0346 0.8008 0.936
## 982 84 1 0.856 0.0357 0.7885 0.929
## 1069 83 1 0.845 0.0367 0.7764 0.920
## 1128 82 1 0.835 0.0377 0.7644 0.912
## 1138 81 1 0.825 0.0386 0.7524 0.904
## 1142 80 1 0.814 0.0395 0.7406 0.896
## 1147 79 1 0.804 0.0403 0.7289 0.887
## 1158 78 2 0.784 0.0418 0.7057 0.870
## 1186 76 1 0.773 0.0425 0.6942 0.861
## 1209 75 1 0.763 0.0432 0.6828 0.852
## 1222 74 1 0.753 0.0438 0.6714 0.844
## 1280 73 1 0.742 0.0444 0.6601 0.835
## 1356 72 1 0.732 0.0450 0.6489 0.826
## 1381 71 1 0.722 0.0455 0.6377 0.817
## 1429 70 1 0.711 0.0460 0.6266 0.807
## 1468 69 1 0.701 0.0465 0.6156 0.798
## 1479 68 1 0.691 0.0469 0.6046 0.789
## 1551 67 1 0.680 0.0473 0.5937 0.780
## 1573 66 1 0.670 0.0477 0.5828 0.771
## 1593 65 1 0.660 0.0481 0.5719 0.761
## 1597 64 1 0.649 0.0484 0.5611 0.752
## 1609 63 1 0.639 0.0488 0.5504 0.742
## 1612 62 2 0.619 0.0493 0.5291 0.723
## 1633 60 2 0.598 0.0498 0.5079 0.704
## 1671 57 1 0.587 0.0500 0.4972 0.694
## 1701 56 1 0.577 0.0502 0.4865 0.684
## 1776 55 1 0.566 0.0504 0.4759 0.674
## 1785 54 1 0.556 0.0505 0.4653 0.664
## 1790 53 1 0.545 0.0506 0.4547 0.654
## 1834 52 1 0.535 0.0507 0.4442 0.644
## 1902 51 1 0.525 0.0508 0.4338 0.634
## 1904 50 1 0.514 0.0509 0.4234 0.624
## 1914 49 1 0.504 0.0509 0.4130 0.614
## 1975 47 1 0.493 0.0509 0.4024 0.603
## 1978 46 1 0.482 0.0509 0.3919 0.593
## 2017 44 1 0.471 0.0510 0.3812 0.582
## 2060 42 1 0.460 0.0510 0.3701 0.571
## 2063 41 1 0.449 0.0509 0.3592 0.561
## 2077 40 1 0.437 0.0509 0.3483 0.550
## 2090 39 1 0.426 0.0508 0.3375 0.538
## 2140 35 1 0.414 0.0508 0.3256 0.527
## 2146 33 1 0.402 0.0508 0.3134 0.514
## 2155 31 1 0.389 0.0508 0.3008 0.502
## 2171 30 1 0.376 0.0507 0.2883 0.489
## 2177 29 1 0.363 0.0506 0.2760 0.477
## 2333 24 1 0.348 0.0507 0.2612 0.463
## 2437 16 1 0.326 0.0520 0.2384 0.445
## 2476 15 1 0.304 0.0528 0.2164 0.428
## 2510 14 1 0.282 0.0533 0.1950 0.409
## 2541 12 1 0.259 0.0538 0.1722 0.389
## 2567 10 1 0.233 0.0543 0.1475 0.368
## 2579 9 1 0.207 0.0541 0.1241 0.346
## 2627 7 1 0.178 0.0539 0.0979 0.322
## 2822 5 1 0.142 0.0535 0.0678 0.297
## 2823 4 1 0.107 0.0506 0.0420 0.270
coxFit_calf <- coxph(Surv(init_change_dat$TimeMeasure,
init_change_dat$Event == 1)~init_change_dat$ResDiff_3G)
init_ch_plot<-ggsurvplot(cox_fit_init, data = init_change_dat,
surv.median.line = "hv", # Add medians survival
# Change legends: title & labels
legend.title = "Change",
legend.labs = c("Ter 1", "Ter 2", "Ter 3"),
# Add p-value and tervals
pval = TRUE,
conf.int = FALSE,
# Add risk table
risk.table = FALSE,
tables.height = 0.2,
tables.theme = theme_cleantable(),
# Color palettes. Use custom color: c("#E7B800", "#2E9FDF"),
# or brewer color (e.g.: "Dark2"), or ggsci color (e.g.: "jco")
palette = mycoloursP[16:40],
ggtheme = theme_classic()
) + xlab("Time in days")
coxFit_meanRLTL_3G<-coxph(Surv(coxData$TimeMeasure, coxData$Event == 1)~coxData$average_resid_3G)
summary(coxFit_meanRLTL_3G)
## Call:
## coxph(formula = Surv(coxData$TimeMeasure, coxData$Event == 1) ~
## coxData$average_resid_3G)
##
## n= 305, number of events= 241
##
## coef exp(coef) se(coef) z Pr(>|z|)
## coxData$average_resid_3G 0.01410 1.01420 0.07886 0.179 0.858
##
## exp(coef) exp(-coef) lower .95 upper .95
## coxData$average_resid_3G 1.014 0.986 0.869 1.184
##
## Concordance= 0.501 (se = 0.02 )
## Likelihood ratio test= 0.03 on 1 df, p=0.9
## Wald test = 0.03 on 1 df, p=0.9
## Score (logrank) test = 0.03 on 1 df, p=0.9
coxFit <- survfit(Surv(coxData$TimeMeasure, coxData$Event == 1)
~ coxData$average_resid_3G)
meanRLTL<-ggsurvplot(coxFit, data = coxData,
surv.median.line = "hv", # Add medians survival
# Change legends: title & labels
legend.title = "Length",
legend.labs = c("Ter 1", "Ter 2", "Ter 3"),
# Add p-value and tervals
pval = TRUE,
conf.int = FALSE,
# Add risk table
risk.table = FALSE,
tables.height = 0.2,
tables.theme = theme_cleantable(),
# Color palettes. Use custom color: c("#E7B800", "#2E9FDF"),
# or brewer color (e.g.: "Dark2"), or ggsci color (e.g.: "jco")
palette = mycoloursP[5:40],
ggtheme = theme_classic()
) + xlab("Time in days")
coxFit<-survfit(Surv(coxData$TimeMeasure, coxData$Event == 1) ~
coxData$rltl_change_3G)
coxFit_meanRLTL_CH_3G<-coxph(Surv(coxData$TimeMeasure, coxData$Event == 1)~coxData$rltl_change_3G)
summary(coxFit_meanRLTL_CH_3G)
## Call:
## coxph(formula = Surv(coxData$TimeMeasure, coxData$Event == 1) ~
## coxData$rltl_change_3G)
##
## n= 305, number of events= 241
##
## coef exp(coef) se(coef) z Pr(>|z|)
## coxData$rltl_change_3G -0.25745 0.77302 0.08656 -2.974 0.00294 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## exp(coef) exp(-coef) lower .95 upper .95
## coxData$rltl_change_3G 0.773 1.294 0.6524 0.9159
##
## Concordance= 0.56 (se = 0.019 )
## Likelihood ratio test= 8.88 on 1 df, p=0.003
## Wald test = 8.85 on 1 df, p=0.003
## Score (logrank) test = 8.92 on 1 df, p=0.003
mean_rltl_change<-ggsurvplot(coxFit, data = coxData,
surv.median.line = "hv", # Add medians survival
# Change legends: title & labels
legend.title = "Change",
legend.labs = c("Ter 1", "Ter 2", "Ter 3"),
# Add p-value and tervals
pval = TRUE,
conf.int = FALSE,
# Add risk table
risk.table = FALSE,
tables.height = 0.2,
tables.theme = theme_cleantable(),
# Color palettes. Use custom color: c("#E7B800", "#2E9FDF"),
# or brewer color (e.g.: "Dark2"), or ggsci color (e.g.: "jco")
palette = mycoloursP[10:40],
ggtheme = theme_classic()
) + xlab("Time in days")
coxFit_meanRLTL_absCH_3G <- coxph(Surv(coxData$TimeMeasure,
coxData$Event == 1) ~ coxData$abs_rltl_change_3G)
summary(coxFit_meanRLTL_absCH_3G)
## Call:
## coxph(formula = Surv(coxData$TimeMeasure, coxData$Event == 1) ~
## coxData$abs_rltl_change_3G)
##
## n= 305, number of events= 241
##
## coef exp(coef) se(coef) z Pr(>|z|)
## coxData$abs_rltl_change_3G 0.17936 1.19645 0.08189 2.19 0.0285 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## exp(coef) exp(-coef) lower .95 upper .95
## coxData$abs_rltl_change_3G 1.196 0.8358 1.019 1.405
##
## Concordance= 0.542 (se = 0.02 )
## Likelihood ratio test= 4.8 on 1 df, p=0.03
## Wald test = 4.8 on 1 df, p=0.03
## Score (logrank) test = 4.82 on 1 df, p=0.03
coxFit<-survfit(Surv(coxData$TimeMeasure, coxData$Event == 1)~coxData$abs_rltl_change_3G)
mean_abs_rltl_change<-ggsurvplot(coxFit, data = coxData,
surv.median.line = "hv", # Add medians survival
# Change legends: title & labels
legend.title = "Abs change",
legend.labs = c("Ter 1", "Ter 2", "Ter 3"),
# Add p-value and tervals
pval = TRUE,
conf.int = FALSE,
# Add risk table
risk.table = FALSE,
tables.height = 0.2,
tables.theme = theme_cleantable(),
# Color palettes. Use custom color: c("#E7B800", "#2E9FDF"),
# or brewer color (e.g.: "Dark2"), or ggsci color (e.g.: "jco")
palette = mycoloursP[35:40],
ggtheme = theme_classic()
) + xlab("Time in days")
surv_plotlist<-list()
surv_plotlist[[1]] <- init_ch_plot
surv_plotlist[[2]] <- mean_abs_rltl_change
surv_plotlist[[3]] <- meanRLTL
surv_plotlist[[4]] <- mean_rltl_change
print(arrange_ggsurvplots(surv_plotlist, print = TRUE, ncol = 4, nrow = 2))
## [[1]]
## NULL
meanRLTL
diseased <- subset(data, data$cull_category != "Herd management" &
data$cull_category != "Accident" &
data$cull_category != "Reason unknown")
diseased <- unique(diseased$recoded_id)
length(diseased)
## [1] 238
diseased_surv <- subset(coxData, coxData$recoded_id %in% diseased)
init_change_dat_restr <- subset(init_change_dat,
init_change_dat$recoded_id %in% diseased)
Reason for culling restricted to disease-related conditions
coxFit_calf_restr <- coxph(Surv(init_change_dat_restr$TimeMeasure,
init_change_dat_restr$Event == 1) ~ init_change_dat_restr$ResDiff_3G)
summary(coxFit_calf_restr)
## Call:
## coxph(formula = Surv(init_change_dat_restr$TimeMeasure, init_change_dat_restr$Event ==
## 1) ~ init_change_dat_restr$ResDiff_3G)
##
## n= 230, number of events= 166
##
## coef exp(coef) se(coef) z Pr(>|z|)
## init_change_dat_restr$ResDiff_3G -0.27174 0.76205 0.09629 -2.822 0.00477 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## exp(coef) exp(-coef) lower .95 upper .95
## init_change_dat_restr$ResDiff_3G 0.7621 1.312 0.631 0.9203
##
## Concordance= 0.557 (se = 0.023 )
## Likelihood ratio test= 8.02 on 1 df, p=0.005
## Wald test = 7.96 on 1 df, p=0.005
## Score (logrank) test = 8.06 on 1 df, p=0.005
cox_fit_init_restr <- survfit(Surv(init_change_dat_restr$TimeMeasure,
init_change_dat_restr$Event == 1) ~ init_change_dat_restr$ResDiff_3G)
summary(cox_fit_init_restr)
## Call: survfit(formula = Surv(init_change_dat_restr$TimeMeasure, init_change_dat_restr$Event ==
## 1) ~ init_change_dat_restr$ResDiff_3G)
##
## init_change_dat_restr$ResDiff_3G=1
## time n.risk n.event survival std.err lower 95% CI upper 95% CI
## 330 77 1 0.987 0.0129 0.9620 1.000
## 699 76 1 0.974 0.0181 0.9391 1.000
## 724 75 1 0.961 0.0221 0.9188 1.000
## 731 74 1 0.948 0.0253 0.8998 0.999
## 742 73 1 0.935 0.0281 0.8816 0.992
## 750 72 1 0.922 0.0305 0.8641 0.984
## 759 71 1 0.909 0.0328 0.8471 0.976
## 760 70 1 0.896 0.0348 0.8305 0.967
## 888 69 1 0.883 0.0366 0.8142 0.958
## 906 68 1 0.870 0.0383 0.7982 0.949
## 923 67 1 0.857 0.0399 0.7824 0.939
## 925 66 1 0.844 0.0413 0.7669 0.929
## 944 65 1 0.831 0.0427 0.7516 0.919
## 958 64 1 0.818 0.0440 0.7364 0.909
## 961 63 1 0.805 0.0451 0.7214 0.899
## 1019 62 1 0.792 0.0462 0.7066 0.888
## 1045 61 1 0.779 0.0473 0.6919 0.878
## 1110 60 1 0.766 0.0482 0.6773 0.867
## 1127 59 1 0.753 0.0491 0.6629 0.856
## 1156 58 1 0.740 0.0500 0.6485 0.845
## 1177 57 1 0.727 0.0508 0.6343 0.834
## 1205 56 1 0.714 0.0515 0.6202 0.823
## 1283 55 1 0.701 0.0522 0.6062 0.811
## 1301 54 1 0.688 0.0528 0.5923 0.800
## 1345 53 1 0.675 0.0534 0.5784 0.788
## 1364 52 1 0.662 0.0539 0.5647 0.777
## 1371 51 1 0.649 0.0544 0.5511 0.765
## 1384 50 1 0.636 0.0548 0.5375 0.753
## 1417 49 1 0.623 0.0552 0.5240 0.742
## 1483 48 1 0.610 0.0556 0.5106 0.730
## 1567 47 1 0.597 0.0559 0.4973 0.718
## 1575 46 1 0.584 0.0562 0.4841 0.706
## 1588 45 1 0.571 0.0564 0.4709 0.693
## 1608 44 1 0.558 0.0566 0.4578 0.681
## 1661 43 1 0.545 0.0567 0.4448 0.669
## 1715 42 1 0.532 0.0569 0.4319 0.656
## 1739 41 1 0.519 0.0569 0.4191 0.644
## 1758 40 1 0.506 0.0570 0.4063 0.631
## 1762 39 1 0.494 0.0570 0.3936 0.619
## 1766 38 2 0.468 0.0569 0.3684 0.593
## 1786 36 1 0.455 0.0567 0.3559 0.581
## 1822 35 1 0.442 0.0566 0.3435 0.568
## 1855 34 1 0.429 0.0564 0.3311 0.555
## 1937 33 1 0.416 0.0562 0.3189 0.542
## 1977 32 1 0.403 0.0559 0.3067 0.528
## 1999 31 1 0.390 0.0556 0.2946 0.515
## 2001 30 1 0.377 0.0552 0.2826 0.502
## 2018 29 1 0.364 0.0548 0.2706 0.489
## 2035 26 1 0.350 0.0545 0.2577 0.474
## 2041 25 1 0.336 0.0541 0.2448 0.460
## 2067 24 2 0.308 0.0530 0.2195 0.431
## 2072 22 1 0.294 0.0524 0.2070 0.417
## 2075 21 1 0.280 0.0518 0.1946 0.402
## 2086 20 1 0.266 0.0510 0.1824 0.387
## 2113 17 1 0.250 0.0504 0.1685 0.371
## 2166 14 1 0.232 0.0498 0.1525 0.354
## 2191 13 1 0.214 0.0491 0.1368 0.336
## 2235 11 1 0.195 0.0484 0.1198 0.317
## 2325 8 1 0.171 0.0481 0.0982 0.296
## 2457 7 1 0.146 0.0470 0.0779 0.274
## 2583 4 1 0.110 0.0474 0.0470 0.256
##
## init_change_dat_restr$ResDiff_3G=2
## time n.risk n.event survival std.err lower 95% CI upper 95% CI
## 628 78 1 0.987 0.0127 0.9625 1.000
## 636 77 1 0.974 0.0179 0.9399 1.000
## 658 76 1 0.962 0.0218 0.9198 1.000
## 749 75 1 0.949 0.0250 0.9010 0.999
## 775 74 1 0.936 0.0277 0.8831 0.992
## 805 73 1 0.923 0.0302 0.8658 0.984
## 822 72 1 0.910 0.0324 0.8490 0.976
## 830 71 1 0.897 0.0344 0.8326 0.967
## 867 70 1 0.885 0.0362 0.8165 0.958
## 908 69 1 0.872 0.0379 0.8007 0.949
## 909 68 1 0.859 0.0394 0.7851 0.940
## 919 67 1 0.846 0.0409 0.7698 0.930
## 923 66 1 0.833 0.0422 0.7546 0.920
## 982 65 1 0.821 0.0435 0.7396 0.910
## 995 64 1 0.808 0.0446 0.7248 0.900
## 1082 63 1 0.795 0.0457 0.7101 0.890
## 1094 62 1 0.782 0.0467 0.6956 0.879
## 1137 61 1 0.769 0.0477 0.6812 0.869
## 1160 60 1 0.756 0.0486 0.6669 0.858
## 1193 59 1 0.744 0.0494 0.6527 0.847
## 1341 58 1 0.731 0.0502 0.6387 0.836
## 1373 57 1 0.718 0.0510 0.6247 0.825
## 1378 56 1 0.705 0.0516 0.6109 0.814
## 1461 55 1 0.692 0.0523 0.5971 0.803
## 1532 54 1 0.679 0.0528 0.5834 0.791
## 1557 53 1 0.667 0.0534 0.5698 0.780
## 1561 52 1 0.654 0.0539 0.5564 0.768
## 1565 51 1 0.641 0.0543 0.5429 0.757
## 1596 50 1 0.628 0.0547 0.5296 0.745
## 1604 49 1 0.615 0.0551 0.5164 0.733
## 1610 48 1 0.603 0.0554 0.5032 0.722
## 1624 47 1 0.590 0.0557 0.4901 0.710
## 1627 46 1 0.577 0.0559 0.4771 0.698
## 1633 45 1 0.564 0.0561 0.4641 0.686
## 1693 44 1 0.551 0.0563 0.4513 0.673
## 1715 43 1 0.538 0.0564 0.4385 0.661
## 1750 42 1 0.526 0.0565 0.4257 0.649
## 1793 41 1 0.513 0.0566 0.4131 0.637
## 1825 40 1 0.500 0.0566 0.4005 0.624
## 1830 39 1 0.487 0.0566 0.3880 0.612
## 1848 38 1 0.474 0.0565 0.3755 0.599
## 1855 37 2 0.449 0.0563 0.3509 0.574
## 1903 35 1 0.436 0.0561 0.3386 0.561
## 1904 34 1 0.423 0.0559 0.3265 0.548
## 1960 33 1 0.410 0.0557 0.3144 0.535
## 1992 31 1 0.397 0.0554 0.3020 0.522
## 2015 28 1 0.383 0.0553 0.2885 0.508
## 2045 27 1 0.369 0.0550 0.2752 0.494
## 2192 21 1 0.351 0.0551 0.2581 0.478
## 2275 18 1 0.332 0.0554 0.2390 0.460
## 2486 9 1 0.295 0.0603 0.1975 0.440
## 2623 7 1 0.253 0.0647 0.1529 0.417
## 2766 4 1 0.189 0.0731 0.0889 0.404
## 2767 3 1 0.126 0.0710 0.0420 0.380
##
## init_change_dat_restr$ResDiff_3G=3
## time n.risk n.event survival std.err lower 95% CI upper 95% CI
## 641 75 1 0.987 0.0132 0.9610 1.000
## 648 74 1 0.973 0.0186 0.9375 1.000
## 721 73 1 0.960 0.0226 0.9167 1.000
## 727 72 1 0.947 0.0259 0.8972 0.999
## 735 71 1 0.933 0.0288 0.8786 0.992
## 798 70 1 0.920 0.0313 0.8606 0.983
## 833 69 1 0.907 0.0336 0.8432 0.975
## 895 68 1 0.893 0.0356 0.8261 0.966
## 897 67 1 0.880 0.0375 0.8094 0.957
## 904 66 1 0.867 0.0393 0.7930 0.947
## 982 65 1 0.853 0.0409 0.7769 0.937
## 1128 64 1 0.840 0.0423 0.7610 0.927
## 1138 63 1 0.827 0.0437 0.7453 0.917
## 1142 62 1 0.813 0.0450 0.7298 0.906
## 1147 61 1 0.800 0.0462 0.7144 0.896
## 1186 60 1 0.787 0.0473 0.6992 0.885
## 1222 59 1 0.773 0.0483 0.6842 0.874
## 1280 58 1 0.760 0.0493 0.6692 0.863
## 1429 57 1 0.747 0.0502 0.6544 0.852
## 1479 56 1 0.733 0.0511 0.6398 0.841
## 1573 55 1 0.720 0.0518 0.6252 0.829
## 1597 54 1 0.707 0.0526 0.6108 0.818
## 1609 53 1 0.693 0.0532 0.5965 0.806
## 1612 52 1 0.680 0.0539 0.5822 0.794
## 1633 51 2 0.653 0.0550 0.5540 0.770
## 1671 48 1 0.640 0.0555 0.5397 0.758
## 1785 47 1 0.626 0.0559 0.5255 0.746
## 1834 46 1 0.612 0.0563 0.5114 0.734
## 1902 45 1 0.599 0.0567 0.4974 0.721
## 1904 44 1 0.585 0.0570 0.4835 0.708
## 1978 42 1 0.571 0.0574 0.4693 0.696
## 2017 40 1 0.557 0.0577 0.4548 0.682
## 2063 38 1 0.542 0.0580 0.4399 0.669
## 2090 37 1 0.528 0.0582 0.4251 0.655
## 2140 33 1 0.512 0.0586 0.4088 0.641
## 2146 31 1 0.495 0.0590 0.3921 0.626
## 2177 29 1 0.478 0.0594 0.3748 0.610
## 2333 24 1 0.458 0.0602 0.3542 0.593
## 2437 16 1 0.430 0.0629 0.3225 0.572
## 2476 15 1 0.401 0.0649 0.2920 0.551
## 2510 14 1 0.372 0.0663 0.2627 0.528
## 2541 12 1 0.341 0.0676 0.2315 0.503
## 2567 10 1 0.307 0.0689 0.1979 0.477
## 2579 9 1 0.273 0.0692 0.1661 0.449
## 2627 7 1 0.234 0.0694 0.1308 0.419
## 2822 5 1 0.187 0.0696 0.0904 0.388
## 2823 4 1 0.140 0.0661 0.0558 0.353
init_ch_plot_restr<-ggsurvplot(cox_fit_init_restr, data = init_change_dat_restr,
surv.median.line = "hv", # Add medians survival
# Change legends: title & labels
legend.title = "Change",
legend.labs = c("Ter 1", "Ter 2", "Ter 3"),
# Add p-value and tervals
pval = TRUE,
conf.int = FALSE,
# Add risk table
risk.table = FALSE,
tables.height = 0.2,
tables.theme = theme_cleantable(),
# Color palettes. Use custom color: c("#E7B800", "#2E9FDF"),
# or brewer color (e.g.: "Dark2"), or ggsci color (e.g.: "jco")
palette = mycoloursP[16:40],
ggtheme = theme_classic()
) + xlab("Time in days")
# Then life-long average RLTL measures
Reason for culling restricted to disease-related conditions
coxFit <- survfit(Surv(diseased_surv$TimeMeasure,
diseased_surv$Event == 1)
~ diseased_surv$average_resid_3G)
coxFit_meanRLTL_3G_restr<-coxph(Surv(diseased_surv$TimeMeasure,
diseased_surv$Event == 1) ~
diseased_surv$average_resid_3G)
summary(coxFit_meanRLTL_3G_restr)
## Call:
## coxph(formula = Surv(diseased_surv$TimeMeasure, diseased_surv$Event ==
## 1) ~ diseased_surv$average_resid_3G)
##
## n= 238, number of events= 174
##
## coef exp(coef) se(coef) z Pr(>|z|)
## diseased_surv$average_resid_3G 0.01288 1.01297 0.09133 0.141 0.888
##
## exp(coef) exp(-coef) lower .95 upper .95
## diseased_surv$average_resid_3G 1.013 0.9872 0.8469 1.212
##
## Concordance= 0.506 (se = 0.024 )
## Likelihood ratio test= 0.02 on 1 df, p=0.9
## Wald test = 0.02 on 1 df, p=0.9
## Score (logrank) test = 0.02 on 1 df, p=0.9
meanRLTL_restr<-ggsurvplot(coxFit, data = diseased_surv,
surv.median.line = "hv", # Add medians survival
# Change legends: title & labels
legend.title = "Length",
legend.labs = c("Ter 1", "Ter 2", "Ter 3"),
# Add p-value and tervals
pval = TRUE,
conf.int = FALSE,
# Add risk table
risk.table = FALSE,
tables.height = 0.2,
tables.theme = theme_cleantable(),
# Color palettes. Use custom color: c("#E7B800", "#2E9FDF"),
# or brewer color (e.g.: "Dark2"), or ggsci color (e.g.: "jco")
palette = mycoloursP[5:40],
ggtheme = theme_classic()
) + xlab("Time in days")
Reason for culling restricted to disease-related conditions
coxFit<-survfit(Surv(diseased_surv$TimeMeasure,
diseased_surv$Event == 1) ~
diseased_surv$rltl_change_3G)
coxFit_meanRLTL_CH_3G_restr <-
coxph(Surv(diseased_surv$TimeMeasure,
diseased_surv$Event == 1) ~
diseased_surv$rltl_change_3G)
summary(coxFit_meanRLTL_CH_3G_restr)
## Call:
## coxph(formula = Surv(diseased_surv$TimeMeasure, diseased_surv$Event ==
## 1) ~ diseased_surv$rltl_change_3G)
##
## n= 238, number of events= 174
##
## coef exp(coef) se(coef) z Pr(>|z|)
## diseased_surv$rltl_change_3G -0.2904 0.7480 0.1028 -2.825 0.00474 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## exp(coef) exp(-coef) lower .95 upper .95
## diseased_surv$rltl_change_3G 0.748 1.337 0.6115 0.915
##
## Concordance= 0.561 (se = 0.023 )
## Likelihood ratio test= 8.06 on 1 df, p=0.005
## Wald test = 7.98 on 1 df, p=0.005
## Score (logrank) test = 8.06 on 1 df, p=0.005
mean_rltl_change_restr <- ggsurvplot(coxFit, data = diseased_surv,
surv.median.line = "hv", # Add medians survival
# Change legends: title & labels
legend.title = "Change",
legend.labs = c("Ter 1", "Ter 2", "Ter 3"),
# Add p-value and tervals
pval = TRUE,
conf.int = FALSE,
# Add risk table
risk.table = FALSE,
tables.height = 0.2,
tables.theme = theme_cleantable(),
# Color palettes. Use custom color: c("#E7B800", "#2E9FDF"),
# or brewer color (e.g.: "Dark2"), or ggsci color (e.g.: "jco")
palette = mycoloursP[10:40],
ggtheme = theme_classic()
) + xlab("Time in days")
Reason for culling restricted to disease-related conditions
coxFit_meanRLTL_absCH_3G_restr <- coxph(Surv(diseased_surv$TimeMeasure,
diseased_surv$Event == 1) ~
diseased_surv$abs_rltl_change_3G)
summary(coxFit_meanRLTL_absCH_3G_restr)
## Call:
## coxph(formula = Surv(diseased_surv$TimeMeasure, diseased_surv$Event ==
## 1) ~ diseased_surv$abs_rltl_change_3G)
##
## n= 238, number of events= 174
##
## coef exp(coef) se(coef) z Pr(>|z|)
## diseased_surv$abs_rltl_change_3G 0.18500 1.20322 0.09682 1.911 0.056 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## exp(coef) exp(-coef) lower .95 upper .95
## diseased_surv$abs_rltl_change_3G 1.203 0.8311 0.9952 1.455
##
## Concordance= 0.539 (se = 0.023 )
## Likelihood ratio test= 3.66 on 1 df, p=0.06
## Wald test = 3.65 on 1 df, p=0.06
## Score (logrank) test = 3.67 on 1 df, p=0.06
coxFit<-survfit(Surv(diseased_surv$TimeMeasure,
diseased_surv$Event == 1) ~
diseased_surv$abs_rltl_change_3G)
mean_abs_rltl_change_restr<-ggsurvplot(coxFit, data = diseased_surv,
surv.median.line = "hv", # Add medians survival
# Change legends: title & labels
legend.title = "Abs change",
legend.labs = c("Ter 1", "Ter 2", "Ter 3"),
# Add p-value and tervals
pval = TRUE,
conf.int = FALSE,
# Add risk table
risk.table = FALSE,
tables.height = 0.2,
tables.theme = theme_cleantable(),
# Color palettes. Use custom color: c("#E7B800", "#2E9FDF"),
# or brewer color (e.g.: "Dark2"), or ggsci color (e.g.: "jco")
palette = mycoloursP[35:40],
ggtheme = theme_classic()
) + xlab("Time in days")
init_ch_plot_restr
mean_abs_rltl_change_restr
meanRLTL_restr
mean_rltl_change_restr
RLTL measures were previously corrected for qPCR plate and row because they have a known effect on our measurements.
hist1 <- ggplot(uData, aes(x = uData$SamplesPerAnimal)) +
geom_histogram(colour = "black", fill = mycoloursP[7], binwidth = 1) +
xlab("Number of samples per animal") +
geom_vline(xintercept = mean(as.numeric(paste(uData$SamplesPerAnimal))), colour = "red") +
theme_classic(20) +
scale_x_continuous(breaks = c(1:8)) #+ annotate("text", x = 1, y = 100, label = "(A)", fontface =2, size = 8)
hist1
## Warning: Use of `uData$SamplesPerAnimal` is discouraged. Use `SamplesPerAnimal`
## instead.
hist2 <- ggplot(data, aes(x = data$residual_rltl_t)) +
geom_histogram(colour = "black", fill = mycoloursP[8]) +
xlab("Adjusted RLTL") +
geom_vline(xintercept = mean(as.numeric(paste(data$residual_rltl_t))), colour = "red") +
# annotate("text", x = -0.4, y = 120, label = "(B)", fontface =2, size = 8)+
theme_classic(20) +
stat_function(
fun = function(x, mean, sd, n) {
n / 25 * dnorm(x = x, mean = mean, sd = sd)
},
args = with(data, c(
mean = mean(data$residual_rltl_t), sd = sd(data$residual_rltl_t), n
= length(data$residual_rltl_t)
))
)
hist2
## Warning: Use of `data$residual_rltl_t` is discouraged. Use `residual_rltl_t`
## instead.
## Warning: Use of `data$residual_rltl_t` is discouraged. Use `residual_rltl_t`
## instead.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
nrow(redData)
## [1] 1020
diff <- as.numeric(paste(redData$diff_rltl_res))
hist3 <- ggplot(redData, aes(x = as.numeric(paste(redData$diff_rltl_res)))) +
geom_histogram(colour = "black", fill = mycoloursP[9]) +
xlab("Adjusted RLTL change") +
geom_vline(xintercept = mean(as.numeric(paste(redData$diff_rltl_res))), colour = "red") +
# annotate("text", x = -0.6, y = 95, label = "(C)", fontface =2, size= 8)+
theme_classic(20) +
stat_function(
fun = function(x, mean, sd, n) {
n / 23 * dnorm(x = x, mean = mean, sd = sd)
},
args = with(redData, c(
mean = mean(as.numeric(paste(redData$diff_rltl_res))), sd = sd(as.numeric(paste(redData$diff_rltl_res))), n
= length(as.numeric(paste(redData$diff_rltl_res)))
))
)
hist3
## Warning: Use of `redData$diff_rltl_res` is discouraged. Use `diff_rltl_res`
## instead.
## Warning: Use of `redData$diff_rltl_res` is discouraged. Use `diff_rltl_res`
## instead.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
grid.arrange(hist1, hist3, ncol = 2)
## Warning: Use of `uData$SamplesPerAnimal` is discouraged. Use `SamplesPerAnimal`
## instead.
## Warning: Use of `redData$diff_rltl_res` is discouraged. Use `diff_rltl_res`
## instead.
## Warning: Use of `redData$diff_rltl_res` is discouraged. Use `diff_rltl_res`
## instead.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
hist2
## Warning: Use of `data$residual_rltl_t` is discouraged. Use `residual_rltl_t`
## instead.
## Warning: Use of `data$residual_rltl_t` is discouraged. Use `residual_rltl_t`
## instead.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
init_hist <- ggplot(init_change_dat, aes(x = init_change_dat$ResDiff)) +
geom_histogram(colour = "black", fill = mycoloursP[10]) +
xlab("Initial RLTL change") +
theme_classic(20) +
geom_vline(xintercept = mean(as.numeric(paste(init_change_dat$ResDiff))), colour = "red") +
# annotate("text", x = -0.6, y = 28, label = "(D)", fontface =2, size= 8) +
stat_function(
fun = function(x, mean, sd, n) {
n / 23 * dnorm(x = x, mean = mean, sd = sd)
},
args = with(init_change_dat, c(
mean = mean(as.numeric(paste(init_change_dat$ResDiff))),
sd = sd(as.numeric(paste(init_change_dat$ResDiff))),
n = length(as.numeric(paste(init_change_dat$ResDiff)))
))
)
init_hist
## Warning: Use of `init_change_dat$ResDiff` is discouraged. Use `ResDiff` instead.
## Warning: Use of `init_change_dat$ResDiff` is discouraged. Use `ResDiff` instead.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
##### Histogram of RLTL at birth
init_rltl0_hist <- ggplot(init_change_dat, aes(x = init_change_dat$RLTL0)) +
geom_histogram(colour = "black", fill = mycoloursP[15]) +
xlab("RLTL at birth") +
theme_classic(20) +
geom_vline(xintercept = mean(as.numeric(paste(init_change_dat$RLTL0))), colour = "red") +
# annotate("text", x = -0.6, y = 28, label = "(D)", fontface =2, size= 8) +
stat_function(
fun = function(x, mean, sd, n) {
n / 23 * dnorm(x = x, mean = mean, sd = sd)
},
args = with(init_change_dat, c(
mean = mean(as.numeric(paste(init_change_dat$RLTL0))),
sd = sd(as.numeric(paste(init_change_dat$RLTL0))),
n = length(as.numeric(paste(init_change_dat$RLTL0)))
))
)
init_rltl0_hist
## Warning: Use of `init_change_dat$RLTL0` is discouraged. Use `RLTL0` instead.
## Warning: Use of `init_change_dat$RLTL0` is discouraged. Use `RLTL0` instead.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
init_rltl1_hist <- ggplot(init_change_dat, aes(x = init_change_dat$RLTL1)) +
geom_histogram(colour = "black", fill = mycoloursP[16]) +
xlab("RLTL at one year") +
theme_classic(20) +
geom_vline(xintercept = mean(as.numeric(paste(init_change_dat$RLTL1))), colour = "red") +
# annotate("text", x = -0.6, y = 28, label = "(D)", fontface =2, size= 8) +
stat_function(
fun = function(x, mean, sd, n) {
n / 23 * dnorm(x = x, mean = mean, sd = sd)
},
args = with(init_change_dat, c(
mean = mean(as.numeric(paste(init_change_dat$RLTL1))),
sd = sd(as.numeric(paste(init_change_dat$RLTL1))),
n = length(as.numeric(paste(init_change_dat$RLTL1)))
))
)
init_rltl1_hist
## Warning: Use of `init_change_dat$RLTL1` is discouraged. Use `RLTL1` instead.
## Warning: Use of `init_change_dat$RLTL1` is discouraged. Use `RLTL1` instead.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
grid.arrange(init_rltl0_hist, init_rltl1_hist, init_hist, ncol = 3)
## Warning: Use of `init_change_dat$RLTL0` is discouraged. Use `RLTL0` instead.
## Warning: Use of `init_change_dat$RLTL0` is discouraged. Use `RLTL0` instead.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Use of `init_change_dat$RLTL1` is discouraged. Use `RLTL1` instead.
## Warning: Use of `init_change_dat$RLTL1` is discouraged. Use `RLTL1` instead.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Use of `init_change_dat$ResDiff` is discouraged. Use `ResDiff` instead.
## Warning: Use of `init_change_dat$ResDiff` is discouraged. Use `ResDiff` instead.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
hist1b <- ggplot(u_more_2, aes(x = SamplesPerAnimal)) +
geom_histogram(colour = "black", fill = mycoloursP[11], binwidth = 1) +
xlab("Number of samples per animal") +
geom_vline(xintercept = mean(as.numeric(paste(u_more_2$SamplesPerAnimal)), na.rm = TRUE), colour = "red") +
annotate("text", x = 0.7, y = 100, label = "(E)", fontface = 2, size = 8) +
theme_classic(20) +
scale_x_continuous(breaks = c(1:8))
# hist1b
For dataframe with more than 2 samples
hist2b <- ggplot(more_2, aes(x = more_2$residual_rltl_t)) +
geom_histogram(colour = "black", fill = mycoloursP[12]) +
xlab("Adjusted RLTL") +
geom_vline(xintercept = mean(as.numeric(paste(more_2$residual_rltl_t))), colour = "red") +
annotate("text", x = -0.4, y = 95, label = "(F)", fontface = 2, size = 8) +
theme_classic(20) +
stat_function(
fun = function(x, mean, sd, n) {
n / 27 * dnorm(x = x, mean = mean, sd = sd)
},
args = with(more_2, c(
mean = mean(more_2$residual_rltl_t), sd = sd(more_2$residual_rltl_t), n
= length(more_2$residual_rltl_t)
))
)
# hist2b
nrow(more_2)
## [1] 992
hist3b <- ggplot(more_2, aes(x = as.numeric(paste(more_2$diff_rltl_res)))) +
geom_histogram(colour = "black", fill = mycoloursP[13]) +
xlab("Adjusted RLTL change") +
geom_vline(xintercept = mean(as.numeric(paste(more_2$diff_rltl_res))), colour = "red") +
annotate("text", x = -0.6, y = 95, label = "(G)", fontface = 2, size = 8) +
theme_classic(20) +
stat_function(
fun = function(x, mean, sd, n) {
n / 23 * dnorm(x = x, mean = mean, sd = sd)
},
args = with(more_2, c(
mean = mean(as.numeric(paste(more_2$diff_rltl_res))), sd = sd(as.numeric(paste(more_2$diff_rltl_res))), n
= length(as.numeric(paste(more_2$diff_rltl_res)))
))
)
# hist3b
variable <- as.numeric(paste(uDeadData$herd_life))
# sqrt might improve normality test outcome slightly...
meanHL <- mean(as.numeric(paste(uDeadData$herd_life)))
prod_lsp_plot <- ggplot(uDeadData, aes(x = as.numeric(paste(uDeadData$herd_life)))) +
geom_histogram(colour = "black", fill = mycoloursP[14]) +
xlab("Productive lifespan in days") +
geom_vline(xintercept = mean(as.numeric(paste(uDeadData$herd_life))), colour = "red") +
# annotate("text", x = 10, y = 19, label = "(H)", fontface =2, size= 8) +
theme_classic(20) +
stat_function(
fun = function(x, mean, sd, n) {
n * 120 * dnorm(x = x, mean = mean, sd = sd)
},
args = with(uDeadData, c(
mean = mean(as.numeric(paste(uDeadData$herd_life))),
sd = sd(as.numeric(paste(uDeadData$herd_life))),
n = length(as.numeric(paste(uDeadData$herd_life)))
))
)
prod_lsp_plot
## Warning: Use of `uDeadData$herd_life` is discouraged. Use `herd_life` instead.
## Warning: Use of `uDeadData$herd_life` is discouraged. Use `herd_life` instead.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
grid.arrange(hist1, hist2, hist3, init_hist, hist1b, hist2b, hist3b, prod_lsp_plot, ncol = 4)
## Warning: Use of `uData$SamplesPerAnimal` is discouraged. Use `SamplesPerAnimal`
## instead.
## Warning: Use of `data$residual_rltl_t` is discouraged. Use `residual_rltl_t`
## instead.
## Warning: Use of `data$residual_rltl_t` is discouraged. Use `residual_rltl_t`
## instead.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Use of `redData$diff_rltl_res` is discouraged. Use `diff_rltl_res`
## instead.
## Warning: Use of `redData$diff_rltl_res` is discouraged. Use `diff_rltl_res`
## instead.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Use of `init_change_dat$ResDiff` is discouraged. Use `ResDiff` instead.
## Warning: Use of `init_change_dat$ResDiff` is discouraged. Use `ResDiff` instead.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Use of `more_2$residual_rltl_t` is discouraged. Use `residual_rltl_t`
## instead.
## Warning: Use of `more_2$residual_rltl_t` is discouraged. Use `residual_rltl_t`
## instead.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Use of `more_2$diff_rltl_res` is discouraged. Use `diff_rltl_res`
## instead.
## Warning: Use of `more_2$diff_rltl_res` is discouraged. Use `diff_rltl_res`
## instead.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Use of `uDeadData$herd_life` is discouraged. Use `herd_life` instead.
## Warning: Use of `uDeadData$herd_life` is discouraged. Use `herd_life` instead.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
RLTL length
# statistical tests for normal distribution of RTL measurements
shapiro.test(data$residual_rltl_t)
##
## Shapiro-Wilk normality test
##
## data: data$residual_rltl_t
## W = 0.989, p-value = 1.967e-08
ks.test(data$residual_rltl_t, pnorm)
##
## One-sample Kolmogorov-Smirnov test
##
## data: data$residual_rltl_t
## D = 0.36744, p-value < 2.2e-16
## alternative hypothesis: two-sided
qqnorm(data$residual_rltl_t)
Adjusted RLTL change
# statistical tests for normal distribution of RTL measurements
shapiro.test(as.numeric(paste(data$diff_rltl_res)))
## Warning in stopifnot(is.numeric(x)): NAs introduced by coercion
##
## Shapiro-Wilk normality test
##
## data: as.numeric(paste(data$diff_rltl_res))
## W = 0.998, p-value = 0.2655
ks.test(as.numeric(paste(data$diff_rltl_res)), pnorm)
## Warning in ks.test(as.numeric(paste(data$diff_rltl_res)), pnorm): NAs introduced
## by coercion
##
## One-sample Kolmogorov-Smirnov test
##
## data: as.numeric(paste(data$diff_rltl_res))
## D = 0.35414, p-value < 2.2e-16
## alternative hypothesis: two-sided
qqnorm(as.numeric(paste(data$diff_rltl_res)))
## Warning in qqnorm(as.numeric(paste(data$diff_rltl_res))): NAs introduced by
## coercion
# statistical tests for normal distribution of difference in RTL residuals
shapiro.test(as.numeric(paste(uDeadData$herd_life)))
##
## Shapiro-Wilk normality test
##
## data: as.numeric(paste(uDeadData$herd_life))
## W = 0.98408, p-value = 0.008487
ks.test(as.numeric(paste(uDeadData$herd_life)), pnorm)
## Warning in ks.test(as.numeric(paste(uDeadData$herd_life)), pnorm): ties should
## not be present for the Kolmogorov-Smirnov test
##
## One-sample Kolmogorov-Smirnov test
##
## data: as.numeric(paste(uDeadData$herd_life))
## D = 1, p-value < 2.2e-16
## alternative hypothesis: two-sided
qqnorm(as.numeric(paste(uDeadData$herd_life)))
# test if mean RLTL change is significantly different from zero:
t.test(as.numeric(paste(redData$diff_rltl_res)), mu=0, alternative="less", conf.level=0.99)
##
## One Sample t-test
##
## data: as.numeric(paste(redData$diff_rltl_res))
## t = -5.8438, df = 1019, p-value = 3.43e-09
## alternative hypothesis: true mean is less than 0
## 99 percent confidence interval:
## -Inf -0.01949685
## sample estimates:
## mean of x
## -0.03242526
count <- nrow(data)
unique_count <- length(unique(data$recoded_id))
sample_year_summ <- summary(as.factor(data$sample_year))
print(paste("There are ", count, " relative leukocyte telomere length (RLTL) measurements of ", unique_count, " animals included in the study.", sep = ""))
## [1] "There are 1325 relative leukocyte telomere length (RLTL) measurements of 305 animals included in the study."
sample_year_summ
## 2008 2009 2010 2011 2012 2013 2014
## 22 91 179 247 266 272 248
Due to our sample routine, animals samples in 2008 all must be calves. This may have an impact on an investigation of the effect of sample year on change in RLTL.
shortening <- subset(redData, as.numeric(paste(redData$diff_rltl_res)) < 0)
elongating <- subset(redData, as.numeric(paste(redData$diff_rltl_res)) > 0)
percent_shortening <- nrow(shortening) / nrow(redData) * 100
percent_shortening
## [1] 56.47059
percent_elongating <- nrow(elongating) / nrow(redData) * 100
percent_elongating
## [1] 43.52941
cor.test(init_change_dat$ResDiff, init_change_dat$sample_interval)
##
## Pearson's product-moment correlation
##
## data: init_change_dat$ResDiff and init_change_dat$sample_interval
## t = 0.13604, df = 289, p-value = 0.8919
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.1070775 0.1228704
## sample estimates:
## cor
## 0.008002275
samp_int <- ggplot(init_change_dat, aes(x = sample_interval, y = ResDiff)) +
geom_point()+
ylab("Change in RLTL")+
xlab("Sample Interval")+
theme_minimal()
samp_int
In calves as well as in adults, the sample interval does not correlate with change in RLTL suggesting that changing rate differs.
# There is only one second time point in the year 2009:
summary(as.factor(redData$sample_year))
## 2009 2010 2011 2012 2013 2014
## 1 88 178 238 269 246
nrow(redData)
## [1] 1020
# this sample is therefore removed:
redData <- subset(redData, redData$sample_year != 2009)
nrow(redData)
## [1] 1019
init_mod <- lmer(as.numeric(paste(redData$diff_rltl_res)) ~
redData$age_y +
redData$feed_group +
redData$genetic_group+ as.factor(redData$birth_year) +
as.factor(redData$sample_year) +
as.numeric(paste(redData$sample_interval))+
redData$health_event_2week +
(1|redData$recoded_id), na.action=na.exclude)
## boundary (singular) fit: see ?isSingular
summary(init_mod)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## as.numeric(paste(redData$diff_rltl_res)) ~ redData$age_y + redData$feed_group +
## redData$genetic_group + as.factor(redData$birth_year) + as.factor(redData$sample_year) +
## as.numeric(paste(redData$sample_interval)) + redData$health_event_2week +
## (1 | redData$recoded_id)
##
## REML criterion at convergence: -599.3
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.4980 -0.6836 0.0252 0.6717 3.5498
##
## Random effects:
## Groups Name Variance Std.Dev.
## redData$recoded_id (Intercept) 0.00000 0.0000
## Residual 0.02953 0.1718
## Number of obs: 1019, groups: redData$recoded_id, 305
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) -1.263e-01 3.879e-02 1.002e+03
## redData$age_y 2.219e-02 1.385e-02 1.002e+03
## redData$feed_group2 -8.381e-03 1.223e-02 1.002e+03
## redData$feed_groupNULL -6.651e-03 1.627e-02 1.002e+03
## redData$genetic_groupS -1.025e-02 1.144e-02 1.002e+03
## as.factor(redData$birth_year)2009 -1.431e-02 2.062e-02 1.002e+03
## as.factor(redData$birth_year)2010 -1.231e-02 2.855e-02 1.002e+03
## as.factor(redData$birth_year)2011 -6.343e-03 3.863e-02 1.002e+03
## as.factor(redData$birth_year)2012 -2.192e-02 5.533e-02 1.002e+03
## as.factor(redData$birth_year)2013 -1.466e-01 1.114e-01 1.002e+03
## as.factor(redData$birth_year)2014 -2.415e-01 1.925e-01 1.002e+03
## as.factor(redData$sample_year)2011 4.158e-02 2.644e-02 1.002e+03
## as.factor(redData$sample_year)2012 6.309e-02 3.329e-02 1.002e+03
## as.factor(redData$sample_year)2013 8.721e-02 4.463e-02 1.002e+03
## as.factor(redData$sample_year)2014 6.360e-02 6.047e-02 1.002e+03
## as.numeric(paste(redData$sample_interval)) -2.685e-06 5.434e-05 1.002e+03
## redData$health_event_2week 1.764e-02 2.447e-02 1.002e+03
## t value Pr(>|t|)
## (Intercept) -3.256 0.00117 **
## redData$age_y 1.602 0.10952
## redData$feed_group2 -0.685 0.49328
## redData$feed_groupNULL -0.409 0.68275
## redData$genetic_groupS -0.896 0.37059
## as.factor(redData$birth_year)2009 -0.694 0.48796
## as.factor(redData$birth_year)2010 -0.431 0.66631
## as.factor(redData$birth_year)2011 -0.164 0.86961
## as.factor(redData$birth_year)2012 -0.396 0.69205
## as.factor(redData$birth_year)2013 -1.316 0.18862
## as.factor(redData$birth_year)2014 -1.255 0.20990
## as.factor(redData$sample_year)2011 1.573 0.11605
## as.factor(redData$sample_year)2012 1.895 0.05835 .
## as.factor(redData$sample_year)2013 1.954 0.05097 .
## as.factor(redData$sample_year)2014 1.052 0.29309
## as.numeric(paste(redData$sample_interval)) -0.049 0.96060
## redData$health_event_2week 0.721 0.47107
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation matrix not shown by default, as p = 17 > 12.
## Use print(x, correlation=TRUE) or
## vcov(x) if you need it
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
anova(init_mod)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF
## redData$age_y 0.075762 0.075762 1 1002
## redData$feed_group 0.014654 0.007327 2 1002
## redData$genetic_group 0.023694 0.023694 1 1002
## as.factor(redData$birth_year) 0.128774 0.021462 6 1002
## as.factor(redData$sample_year) 0.312340 0.078085 4 1002
## as.numeric(paste(redData$sample_interval)) 0.000072 0.000072 1 1002
## redData$health_event_2week 0.015351 0.015351 1 1002
## F value Pr(>F)
## redData$age_y 2.5657 0.10952
## redData$feed_group 0.2481 0.78031
## redData$genetic_group 0.8024 0.37059
## as.factor(redData$birth_year) 0.7268 0.62806
## as.factor(redData$sample_year) 2.6443 0.03235 *
## as.numeric(paste(redData$sample_interval)) 0.0024 0.96060
## redData$health_event_2week 0.5199 0.47107
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AIC(init_mod)
## [1] -561.2719
# There is a warning that this model is singular which is due to the random effect variance structure. It means that the variance due to the animal ID is not significantly different from 0. Although this may be a problem for some models, I think in this case it is not. It simply means that there is no variation between animals in the RLTL change and that is to be expected here, because the variance within animals is much larger than the variance between animals.
# Sample year is statistically significant, but it might only be signifgicant due to the design of our study. Becasue we wanted to have repeat measurements for all animals with the first measurement taken with the first 15 days of life, sampling in the first year only included calves which have been shown before to have longer telomeres than adults and to shorten them in their first year of life. So is the year effect simply driven by that? If so, it should vanish after excluding samples taken within the two years
init_mod_out <- as.data.frame(VarCorr(init_mod),comp = c("Variance", "Std.Dev."))
repET <- init_mod_out[1,4]/sum(init_mod_out[1:nrow(init_mod_out),4])
repET
## [1] 0
summary(as.factor(data$sample_year))
## 2008 2009 2010 2011 2012 2013 2014
## 22 91 179 247 266 272 248
test_dat<-subset(data, data$sample_year != 2008)
test_dat<-subset(test_dat, test_dat$sample_year != 2009)
long_dat <- subset(test_dat, test_dat$diff_rltl_res != "NULL")
late_mod <- lmer(as.numeric(paste(long_dat$diff_rltl_res)) ~
long_dat$age_y +
long_dat$feed_group +
long_dat$genetic_group +
as.factor(long_dat$birth_year) +
as.factor(long_dat$sample_year) +
as.numeric(paste(long_dat$sample_interval)) +
long_dat$health_event_2week +
(1|long_dat$recoded_id),
na.action=na.exclude)
## boundary (singular) fit: see ?isSingular
summary(late_mod)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: as.numeric(paste(long_dat$diff_rltl_res)) ~ long_dat$age_y +
## long_dat$feed_group + long_dat$genetic_group + as.factor(long_dat$birth_year) +
## as.factor(long_dat$sample_year) + as.numeric(paste(long_dat$sample_interval)) +
## long_dat$health_event_2week + (1 | long_dat$recoded_id)
##
## REML criterion at convergence: -599.3
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.4980 -0.6836 0.0252 0.6717 3.5498
##
## Random effects:
## Groups Name Variance Std.Dev.
## long_dat$recoded_id (Intercept) 0.00000 0.0000
## Residual 0.02953 0.1718
## Number of obs: 1019, groups: long_dat$recoded_id, 305
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) -1.263e-01 3.879e-02 1.002e+03
## long_dat$age_y 2.219e-02 1.385e-02 1.002e+03
## long_dat$feed_group2 -8.381e-03 1.223e-02 1.002e+03
## long_dat$feed_groupNULL -6.651e-03 1.627e-02 1.002e+03
## long_dat$genetic_groupS -1.025e-02 1.144e-02 1.002e+03
## as.factor(long_dat$birth_year)2009 -1.431e-02 2.062e-02 1.002e+03
## as.factor(long_dat$birth_year)2010 -1.231e-02 2.855e-02 1.002e+03
## as.factor(long_dat$birth_year)2011 -6.343e-03 3.863e-02 1.002e+03
## as.factor(long_dat$birth_year)2012 -2.192e-02 5.533e-02 1.002e+03
## as.factor(long_dat$birth_year)2013 -1.466e-01 1.114e-01 1.002e+03
## as.factor(long_dat$birth_year)2014 -2.415e-01 1.925e-01 1.002e+03
## as.factor(long_dat$sample_year)2011 4.158e-02 2.644e-02 1.002e+03
## as.factor(long_dat$sample_year)2012 6.309e-02 3.329e-02 1.002e+03
## as.factor(long_dat$sample_year)2013 8.721e-02 4.463e-02 1.002e+03
## as.factor(long_dat$sample_year)2014 6.360e-02 6.047e-02 1.002e+03
## as.numeric(paste(long_dat$sample_interval)) -2.685e-06 5.434e-05 1.002e+03
## long_dat$health_event_2week 1.764e-02 2.447e-02 1.002e+03
## t value Pr(>|t|)
## (Intercept) -3.256 0.00117 **
## long_dat$age_y 1.602 0.10952
## long_dat$feed_group2 -0.685 0.49328
## long_dat$feed_groupNULL -0.409 0.68275
## long_dat$genetic_groupS -0.896 0.37059
## as.factor(long_dat$birth_year)2009 -0.694 0.48796
## as.factor(long_dat$birth_year)2010 -0.431 0.66631
## as.factor(long_dat$birth_year)2011 -0.164 0.86961
## as.factor(long_dat$birth_year)2012 -0.396 0.69205
## as.factor(long_dat$birth_year)2013 -1.316 0.18862
## as.factor(long_dat$birth_year)2014 -1.255 0.20990
## as.factor(long_dat$sample_year)2011 1.573 0.11605
## as.factor(long_dat$sample_year)2012 1.895 0.05835 .
## as.factor(long_dat$sample_year)2013 1.954 0.05097 .
## as.factor(long_dat$sample_year)2014 1.052 0.29309
## as.numeric(paste(long_dat$sample_interval)) -0.049 0.96060
## long_dat$health_event_2week 0.721 0.47107
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation matrix not shown by default, as p = 17 > 12.
## Use print(x, correlation=TRUE) or
## vcov(x) if you need it
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
anova(late_mod)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF
## long_dat$age_y 0.075762 0.075762 1 1002
## long_dat$feed_group 0.014654 0.007327 2 1002
## long_dat$genetic_group 0.023694 0.023694 1 1002
## as.factor(long_dat$birth_year) 0.128774 0.021462 6 1002
## as.factor(long_dat$sample_year) 0.312340 0.078085 4 1002
## as.numeric(paste(long_dat$sample_interval)) 0.000072 0.000072 1 1002
## long_dat$health_event_2week 0.015351 0.015351 1 1002
## F value Pr(>F)
## long_dat$age_y 2.5657 0.10952
## long_dat$feed_group 0.2481 0.78031
## long_dat$genetic_group 0.8024 0.37059
## as.factor(long_dat$birth_year) 0.7268 0.62806
## as.factor(long_dat$sample_year) 2.6443 0.03235 *
## as.numeric(paste(long_dat$sample_interval)) 0.0024 0.96060
## long_dat$health_event_2week 0.5199 0.47107
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AIC(late_mod)
## [1] -561.2719
# sample year remains statistically significant.
red_mod <- lmer(as.numeric(paste(redData$diff_rltl_res)) ~
redData$age_y +
redData$feed_group +
redData$genetic_group+
as.factor(redData$sample_year) +
as.numeric(paste(redData$sample_interval)) +
(1|redData$recoded_id),
na.action=na.exclude)
## boundary (singular) fit: see ?isSingular
summary(red_mod)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## as.numeric(paste(redData$diff_rltl_res)) ~ redData$age_y + redData$feed_group +
## redData$genetic_group + as.factor(redData$sample_year) +
## as.numeric(paste(redData$sample_interval)) + (1 | redData$recoded_id)
##
## REML criterion at convergence: -627.8
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.5005 -0.6963 0.0198 0.6784 3.5199
##
## Random effects:
## Groups Name Variance Std.Dev.
## redData$recoded_id (Intercept) 0.00000 0.0000
## Residual 0.02947 0.1717
## Number of obs: 1019, groups: redData$recoded_id, 305
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) -1.415e-01 2.814e-02 1.009e+03
## redData$age_y 2.571e-02 6.026e-03 1.009e+03
## redData$feed_group2 -1.045e-02 1.206e-02 1.009e+03
## redData$feed_groupNULL -1.499e-02 1.546e-02 1.009e+03
## redData$genetic_groupS -1.262e-02 1.134e-02 1.009e+03
## as.factor(redData$sample_year)2011 3.952e-02 2.266e-02 1.009e+03
## as.factor(redData$sample_year)2012 6.065e-02 2.218e-02 1.009e+03
## as.factor(redData$sample_year)2013 8.106e-02 2.358e-02 1.009e+03
## as.factor(redData$sample_year)2014 5.035e-02 2.745e-02 1.009e+03
## as.numeric(paste(redData$sample_interval)) 1.029e-05 5.207e-05 1.009e+03
## t value Pr(>|t|)
## (Intercept) -5.029 5.83e-07 ***
## redData$age_y 4.266 2.18e-05 ***
## redData$feed_group2 -0.867 0.386405
## redData$feed_groupNULL -0.969 0.332699
## redData$genetic_groupS -1.113 0.265975
## as.factor(redData$sample_year)2011 1.744 0.081532 .
## as.factor(redData$sample_year)2012 2.735 0.006353 **
## as.factor(redData$sample_year)2013 3.438 0.000609 ***
## as.factor(redData$sample_year)2014 1.834 0.066902 .
## as.numeric(paste(redData$sample_interval)) 0.198 0.843439
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) rdDt$_ rdD$_2 rD$_NU rdD$_S a.(D$_)2011 a.(D$_)2012
## redData$g_y -0.203
## rdDt$fd_gr2 -0.219 -0.099
## rdDt$f_NULL -0.197 0.114 0.370
## rdDt$gntc_S -0.263 0.090 -0.029 0.243
## a.(D$_)2011 -0.460 -0.141 0.018 -0.065 -0.017
## a.(D$_)2012 -0.493 -0.259 0.034 -0.028 -0.013 0.703
## a.(D$_)2013 -0.373 -0.442 0.045 -0.077 -0.041 0.694 0.755
## a.(D$_)2014 -0.215 -0.615 0.047 -0.092 -0.074 0.633 0.708
## as.n((D$_)) -0.661 -0.033 0.047 -0.034 0.071 -0.045 0.016
## a.(D$_)2013 a.(D$_)2014
## redData$g_y
## rdDt$fd_gr2
## rdDt$f_NULL
## rdDt$gntc_S
## a.(D$_)2011
## a.(D$_)2012
## a.(D$_)2013
## a.(D$_)2014 0.798
## as.n((D$_)) -0.047 -0.113
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
anova(red_mod)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value
## redData$age_y 0.53630 0.53630 1 1009 18.2001
## redData$feed_group 0.03650 0.01825 2 1009 0.6193
## redData$genetic_group 0.03650 0.03650 1 1009 1.2388
## as.factor(redData$sample_year) 0.45210 0.11303 4 1009 3.8357
## as.numeric(paste(redData$sample_interval)) 0.00115 0.00115 1 1009 0.0390
## Pr(>F)
## redData$age_y 2.176e-05 ***
## redData$feed_group 0.538542
## redData$genetic_group 0.265975
## as.factor(redData$sample_year) 0.004224 **
## as.numeric(paste(redData$sample_interval)) 0.843439
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AIC(red_mod)
## [1] -603.817
tableS3 <- as.data.frame(round(coef(summary(red_mod)),3))
tableS3
## Estimate Std. Error df t value
## (Intercept) -0.142 0.028 1009 -5.029
## redData$age_y 0.026 0.006 1009 4.266
## redData$feed_group2 -0.010 0.012 1009 -0.867
## redData$feed_groupNULL -0.015 0.015 1009 -0.969
## redData$genetic_groupS -0.013 0.011 1009 -1.113
## as.factor(redData$sample_year)2011 0.040 0.023 1009 1.744
## as.factor(redData$sample_year)2012 0.061 0.022 1009 2.735
## as.factor(redData$sample_year)2013 0.081 0.024 1009 3.438
## as.factor(redData$sample_year)2014 0.050 0.027 1009 1.834
## as.numeric(paste(redData$sample_interval)) 0.000 0.000 1009 0.198
## Pr(>|t|)
## (Intercept) 0.000
## redData$age_y 0.000
## redData$feed_group2 0.386
## redData$feed_groupNULL 0.333
## redData$genetic_groupS 0.266
## as.factor(redData$sample_year)2011 0.082
## as.factor(redData$sample_year)2012 0.006
## as.factor(redData$sample_year)2013 0.001
## as.factor(redData$sample_year)2014 0.067
## as.numeric(paste(redData$sample_interval)) 0.843
tableS4 <- as.data.frame(anova(red_mod))
tableS4
## Sum Sq Mean Sq NumDF DenDF
## redData$age_y 0.536302630 0.536302630 1 1009
## redData$feed_group 0.036496026 0.018248013 2 1009
## redData$genetic_group 0.036502536 0.036502536 1 1009
## as.factor(redData$sample_year) 0.452100679 0.113025170 4 1009
## as.numeric(paste(redData$sample_interval)) 0.001149941 0.001149941 1 1009
## F value Pr(>F)
## redData$age_y 18.20011295 2.175661e-05
## redData$feed_group 0.61926957 5.385420e-01
## redData$genetic_group 1.23876005 2.659752e-01
## as.factor(redData$sample_year) 3.83565312 4.224364e-03
## as.numeric(paste(redData$sample_interval)) 0.03902473 8.434395e-01
red_mod_out <- as.data.frame(VarCorr(red_mod),comp = c("Variance", "Std.Dev."))
repET <- red_mod_out[1,4]/sum(red_mod_out[1:nrow(red_mod_out),4])
repET
## [1] 0
Absolute change
red_mod_abs <- lmer(abs(as.numeric(paste(redData$diff_rltl_res))) ~
redData$age_y +
redData$feed_group +
redData$genetic_group+
as.factor(redData$sample_year) +
as.numeric(paste(redData$sample_interval)) +
(1|redData$recoded_id),
na.action=na.exclude)
summary(red_mod_abs)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: abs(as.numeric(paste(redData$diff_rltl_res))) ~ redData$age_y +
## redData$feed_group + redData$genetic_group + as.factor(redData$sample_year) +
## as.numeric(paste(redData$sample_interval)) + (1 | redData$recoded_id)
##
## REML criterion at convergence: -1571.5
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.7277 -0.7653 -0.1849 0.5909 5.0501
##
## Random effects:
## Groups Name Variance Std.Dev.
## redData$recoded_id (Intercept) 0.0005739 0.02396
## Residual 0.0110340 0.10504
## Number of obs: 1019, groups: redData$recoded_id, 305
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) 1.855e-01 1.770e-02 9.991e+02
## redData$age_y -8.741e-03 3.925e-03 4.596e+02
## redData$feed_group2 7.939e-03 8.085e-03 2.201e+02
## redData$feed_groupNULL -1.941e-03 1.024e-02 2.905e+02
## redData$genetic_groupS 1.363e-02 7.580e-03 2.350e+02
## as.factor(redData$sample_year)2011 -3.229e-02 1.406e-02 9.305e+02
## as.factor(redData$sample_year)2012 -2.383e-02 1.394e-02 1.001e+03
## as.factor(redData$sample_year)2013 -2.487e-02 1.505e-02 7.770e+02
## as.factor(redData$sample_year)2014 -9.352e-03 1.776e-02 5.455e+02
## as.numeric(paste(redData$sample_interval)) -2.306e-05 3.255e-05 1.001e+03
## t value Pr(>|t|)
## (Intercept) 10.483 <2e-16 ***
## redData$age_y -2.227 0.0264 *
## redData$feed_group2 0.982 0.3272
## redData$feed_groupNULL -0.190 0.8498
## redData$genetic_groupS 1.797 0.0735 .
## as.factor(redData$sample_year)2011 -2.297 0.0219 *
## as.factor(redData$sample_year)2012 -1.710 0.0876 .
## as.factor(redData$sample_year)2013 -1.652 0.0989 .
## as.factor(redData$sample_year)2014 -0.527 0.5987
## as.numeric(paste(redData$sample_interval)) -0.709 0.4787
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) rdDt$_ rdD$_2 rD$_NU rdD$_S a.(D$_)2011 a.(D$_)2012
## redData$g_y -0.186
## rdDt$fd_gr2 -0.230 -0.090
## rdDt$f_NULL -0.216 0.119 0.373
## rdDt$gntc_S -0.275 0.092 -0.029 0.241
## a.(D$_)2011 -0.448 -0.168 0.017 -0.064 -0.017
## a.(D$_)2012 -0.477 -0.304 0.034 -0.033 -0.016 0.708
## a.(D$_)2013 -0.355 -0.489 0.044 -0.082 -0.045 0.695 0.767
## a.(D$_)2014 -0.202 -0.653 0.047 -0.097 -0.076 0.633 0.721
## as.n((D$_)) -0.661 -0.026 0.040 -0.029 0.071 -0.047 0.016
## a.(D$_)2013 a.(D$_)2014
## redData$g_y
## rdDt$fd_gr2
## rdDt$f_NULL
## rdDt$gntc_S
## a.(D$_)2011
## a.(D$_)2012
## a.(D$_)2013
## a.(D$_)2014 0.814
## as.n((D$_)) -0.047 -0.111
anova(red_mod_abs)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF
## redData$age_y 0.054736 0.054736 1 459.63
## redData$feed_group 0.014592 0.007296 2 255.93
## redData$genetic_group 0.035649 0.035649 1 234.95
## as.factor(redData$sample_year) 0.092171 0.023043 4 820.58
## as.numeric(paste(redData$sample_interval)) 0.005541 0.005541 1 1000.59
## F value Pr(>F)
## redData$age_y 4.9606 0.02641 *
## redData$feed_group 0.6612 0.51709
## redData$genetic_group 3.2308 0.07355 .
## as.factor(redData$sample_year) 2.0883 0.08049 .
## as.numeric(paste(redData$sample_interval)) 0.5022 0.47872
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AIC(red_mod_abs)
## [1] -1547.479
red_mod_abs_out <- as.data.frame(VarCorr(red_mod_abs),comp = c("Variance", "Std.Dev."))
repET <- red_mod_abs_out[1,4]/sum(red_mod_abs_out[1:nrow(red_mod_abs_out),4])
repET
## [1] 0.04943996
red_mod_fac<-lmer(as.numeric(paste(redData$diff_rltl_res)) ~
redData$AgeGroup +
redData$feed_group +
redData$genetic_group+
as.factor(redData$sample_year) +
as.numeric(paste(redData$sample_interval)) +
(1|redData$recoded_id),
na.action=na.exclude)
## boundary (singular) fit: see ?isSingular
summary(red_mod_fac)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: as.numeric(paste(redData$diff_rltl_res)) ~ redData$AgeGroup +
## redData$feed_group + redData$genetic_group + as.factor(redData$sample_year) +
## as.numeric(paste(redData$sample_interval)) + (1 | redData$recoded_id)
##
## REML criterion at convergence: -627
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.6485 -0.6865 0.0273 0.6787 3.3620
##
## Random effects:
## Groups Name Variance Std.Dev.
## redData$recoded_id (Intercept) 0.00000 0.0000
## Residual 0.02956 0.1719
## Number of obs: 1019, groups: redData$recoded_id, 305
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) -5.148e-02 3.238e-02 1.009e+03
## redData$AgeGroupyoung -7.262e-02 1.872e-02 1.009e+03
## redData$feed_group2 -5.832e-03 1.202e-02 1.009e+03
## redData$feed_groupNULL -1.786e-02 1.543e-02 1.009e+03
## redData$genetic_groupS -1.565e-02 1.131e-02 1.009e+03
## as.factor(redData$sample_year)2011 3.683e-02 2.286e-02 1.009e+03
## as.factor(redData$sample_year)2012 6.164e-02 2.229e-02 1.009e+03
## as.factor(redData$sample_year)2013 9.536e-02 2.256e-02 1.009e+03
## as.factor(redData$sample_year)2014 9.386e-02 2.289e-02 1.009e+03
## as.numeric(paste(redData$sample_interval)) -7.172e-05 5.697e-05 1.009e+03
## t value Pr(>|t|)
## (Intercept) -1.590 0.112162
## redData$AgeGroupyoung -3.880 0.000111 ***
## redData$feed_group2 -0.485 0.627658
## redData$feed_groupNULL -1.157 0.247431
## redData$genetic_groupS -1.383 0.166882
## as.factor(redData$sample_year)2011 1.611 0.107479
## as.factor(redData$sample_year)2012 2.765 0.005797 **
## as.factor(redData$sample_year)2013 4.226 2.59e-05 ***
## as.factor(redData$sample_year)2014 4.100 4.46e-05 ***
## as.numeric(paste(redData$sample_interval)) -1.259 0.208366
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) rdD$AG rdD$_2 rD$_NU rdD$_S a.(D$_)2011 a.(D$_)2012
## rdDt$AgGrpy -0.523
## rdDt$fd_gr2 -0.214 0.010
## rdDt$f_NULL -0.111 -0.078 0.383
## rdDt$gntc_S -0.198 -0.031 -0.020 0.237
## a.(D$_)2011 -0.518 0.184 0.006 -0.063 -0.010
## a.(D$_)2012 -0.615 0.272 0.012 -0.020 0.002 0.709
## a.(D$_)2013 -0.602 0.345 0.005 -0.055 -0.012 0.720 0.761
## a.(D$_)2014 -0.523 0.321 -0.013 -0.051 -0.032 0.710 0.744
## as.n((D$_)) -0.743 0.404 0.044 -0.059 0.056 0.029 0.117
## a.(D$_)2013 a.(D$_)2014
## rdDt$AgGrpy
## rdDt$fd_gr2
## rdDt$f_NULL
## rdDt$gntc_S
## a.(D$_)2011
## a.(D$_)2012
## a.(D$_)2013
## a.(D$_)2014 0.772
## as.n((D$_)) 0.080 -0.017
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
anova(red_mod_fac)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value
## redData$AgeGroup 0.44503 0.44503 1 1009 15.0564
## redData$feed_group 0.03965 0.01982 2 1009 0.6707
## redData$genetic_group 0.05656 0.05656 1 1009 1.9135
## as.factor(redData$sample_year) 0.80475 0.20119 4 1009 6.8066
## as.numeric(paste(redData$sample_interval)) 0.04684 0.04684 1 1009 1.5848
## Pr(>F)
## redData$AgeGroup 0.0001111 ***
## redData$feed_group 0.5115971
## redData$genetic_group 0.1668816
## as.factor(redData$sample_year) 2.09e-05 ***
## as.numeric(paste(redData$sample_interval)) 0.2083656
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AIC(red_mod_fac)
## [1] -602.9877
anova(red_mod, red_mod_fac)
## refitting model(s) with ML (instead of REML)
## Data: NULL
## Models:
## red_mod: as.numeric(paste(redData$diff_rltl_res)) ~ redData$age_y + redData$feed_group +
## red_mod: redData$genetic_group + as.factor(redData$sample_year) +
## red_mod: as.numeric(paste(redData$sample_interval)) + (1 | redData$recoded_id)
## red_mod_fac: as.numeric(paste(redData$diff_rltl_res)) ~ redData$AgeGroup +
## red_mod_fac: redData$feed_group + redData$genetic_group + as.factor(redData$sample_year) +
## red_mod_fac: as.numeric(paste(redData$sample_interval)) + (1 | redData$recoded_id)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## red_mod 12 -685.70 -626.58 354.85 -709.70
## red_mod_fac 12 -682.58 -623.46 353.29 -706.58 0 0
#t test with average productivity in the model for animals that have productivity measurements:
PData <- subset(redData, redData$amp_305_lactation != "NULL")
nrow(PData)
## [1] 917
length(unique(PData$recoded_id))
## [1] 253
rescaled_prod <- as.numeric(paste(PData$amp_305_lactation))/1000
# milk productivity measures are on a completely differenc scale and are therefore re-scaled by dividing them by 1000
prod_mod <- lmer(as.numeric(paste(PData$diff_rltl_res)) ~
PData$age_y +
PData$feed_group +
PData$genetic_group +
as.factor(PData$sample_year) +
as.numeric(paste(PData$sample_interval)) +
rescaled_prod +
(1|PData$recoded_id),
na.action=na.exclude)
## boundary (singular) fit: see ?isSingular
summary(prod_mod)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## as.numeric(paste(PData$diff_rltl_res)) ~ PData$age_y + PData$feed_group +
## PData$genetic_group + as.factor(PData$sample_year) + as.numeric(paste(PData$sample_interval)) +
## rescaled_prod + (1 | PData$recoded_id)
##
## REML criterion at convergence: -555.3
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.5406 -0.6846 0.0104 0.7107 3.4856
##
## Random effects:
## Groups Name Variance Std.Dev.
## PData$recoded_id (Intercept) 0.00000 0.0000
## Residual 0.02931 0.1712
## Number of obs: 917, groups: PData$recoded_id, 253
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) -1.427e-01 3.518e-02 9.060e+02
## PData$age_y 2.069e-02 6.722e-03 9.060e+02
## PData$feed_group2 -5.600e-03 1.305e-02 9.060e+02
## PData$feed_groupNULL 9.214e-03 2.429e-02 9.060e+02
## PData$genetic_groupS -1.131e-02 1.222e-02 9.060e+02
## as.factor(PData$sample_year)2011 3.763e-02 2.357e-02 9.060e+02
## as.factor(PData$sample_year)2012 5.980e-02 2.300e-02 9.060e+02
## as.factor(PData$sample_year)2013 8.593e-02 2.515e-02 9.060e+02
## as.factor(PData$sample_year)2014 6.353e-02 2.981e-02 9.060e+02
## as.numeric(paste(PData$sample_interval)) -2.573e-05 5.582e-05 9.060e+02
## rescaled_prod 2.735e-03 2.840e-03 9.060e+02
## t value Pr(>|t|)
## (Intercept) -4.057 5.41e-05 ***
## PData$age_y 3.078 0.002150 **
## PData$feed_group2 -0.429 0.667985
## PData$feed_groupNULL 0.379 0.704485
## PData$genetic_groupS -0.926 0.354903
## as.factor(PData$sample_year)2011 1.597 0.110645
## as.factor(PData$sample_year)2012 2.600 0.009470 **
## as.factor(PData$sample_year)2013 3.417 0.000662 ***
## as.factor(PData$sample_year)2014 2.131 0.033321 *
## as.numeric(paste(PData$sample_interval)) -0.461 0.644976
## rescaled_prod 0.963 0.335712
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) PDt$g_ PDt$_2 PD$_NU PDt$_S a.(PD$_)2011 a.(PD$_)2012
## PData$age_y -0.081
## PDt$fd_grp2 -0.369 -0.163
## PDt$fd_NULL -0.409 -0.143 0.452
## PDt$gntc_gS -0.032 0.102 -0.130 -0.006
## a.(PD$_)2011 -0.389 -0.149 0.025 -0.001 -0.030
## a.(PD$_)2012 -0.417 -0.284 0.050 0.048 -0.034 0.693
## a.(PD$_)2013 -0.327 -0.493 0.083 0.082 -0.064 0.671 0.750
## a.(PD$_)2014 -0.201 -0.662 0.089 0.091 -0.080 0.604 0.702
## as.((PD$_)) -0.556 0.008 0.033 -0.064 0.059 -0.028 0.014
## rescald_prd -0.542 -0.178 0.376 0.599 -0.283 0.016 0.039
## a.(PD$_)2013 a.(PD$_)2014 a.((PD
## PData$age_y
## PDt$fd_grp2
## PDt$fd_NULL
## PDt$gntc_gS
## a.(PD$_)2011
## a.(PD$_)2012
## a.(PD$_)2013
## a.(PD$_)2014 0.805
## as.((PD$_)) -0.065 -0.124
## rescald_prd 0.094 0.099 -0.036
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
anova(prod_mod)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value
## PData$age_y 0.27757 0.277574 1 906 9.4712
## PData$feed_group 0.01751 0.008753 2 906 0.2987
## PData$genetic_group 0.02511 0.025108 1 906 0.8567
## as.factor(PData$sample_year) 0.40514 0.101285 4 906 3.4560
## as.numeric(paste(PData$sample_interval)) 0.00623 0.006226 1 906 0.2124
## rescaled_prod 0.02719 0.027189 1 906 0.9277
## Pr(>F)
## PData$age_y 0.002150 **
## PData$feed_group 0.741877
## PData$genetic_group 0.354903
## as.factor(PData$sample_year) 0.008192 **
## as.numeric(paste(PData$sample_interval)) 0.644976
## rescaled_prod 0.335712
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
tableS5 <- as.data.frame(round(coef(summary(prod_mod)),3))
tableS5
## Estimate Std. Error df t value
## (Intercept) -0.143 0.035 906 -4.057
## PData$age_y 0.021 0.007 906 3.078
## PData$feed_group2 -0.006 0.013 906 -0.429
## PData$feed_groupNULL 0.009 0.024 906 0.379
## PData$genetic_groupS -0.011 0.012 906 -0.926
## as.factor(PData$sample_year)2011 0.038 0.024 906 1.597
## as.factor(PData$sample_year)2012 0.060 0.023 906 2.600
## as.factor(PData$sample_year)2013 0.086 0.025 906 3.417
## as.factor(PData$sample_year)2014 0.064 0.030 906 2.131
## as.numeric(paste(PData$sample_interval)) 0.000 0.000 906 -0.461
## rescaled_prod 0.003 0.003 906 0.963
## Pr(>|t|)
## (Intercept) 0.000
## PData$age_y 0.002
## PData$feed_group2 0.668
## PData$feed_groupNULL 0.704
## PData$genetic_groupS 0.355
## as.factor(PData$sample_year)2011 0.111
## as.factor(PData$sample_year)2012 0.009
## as.factor(PData$sample_year)2013 0.001
## as.factor(PData$sample_year)2014 0.033
## as.numeric(paste(PData$sample_interval)) 0.645
## rescaled_prod 0.336
tableS6 <- as.data.frame(anova(prod_mod))
tableS6
## Sum Sq Mean Sq NumDF DenDF
## PData$age_y 0.277574210 0.277574210 1 906
## PData$feed_group 0.017506358 0.008753179 2 906
## PData$genetic_group 0.025108197 0.025108197 1 906
## as.factor(PData$sample_year) 0.405141736 0.101285434 4 906
## as.numeric(paste(PData$sample_interval)) 0.006225897 0.006225897 1 906
## rescaled_prod 0.027188984 0.027188984 1 906
## F value Pr(>F)
## PData$age_y 9.4711963 0.002150018
## PData$feed_group 0.2986699 0.741877212
## PData$genetic_group 0.8567246 0.354903384
## as.factor(PData$sample_year) 3.4559919 0.008191816
## as.numeric(paste(PData$sample_interval)) 0.2124358 0.644975545
## rescaled_prod 0.9277238 0.335712088
One factor that may influence telomere length dynamics in dairy cattle and explain yearly variation in telomere length attrition is weather. Previously, harsher weather has been shown to correlate with more telomere length attrition in the bat species Myotis myotis (REFS). Also, yearly effects on telomere length that may indicate environmental factors such as weather have been observed in Soay sheep and European badgers (REFS). In two cross-sectional studies, black bears that live at a higher altitude (and therefore colder climate) were shown to have shorter telomeres and similarly Roe deer living in a harsher habitat had shorter telomeres than those animals in an habitat with milder weather and better food resources. Dairy cattle nowadays are often kept in stables that provide a roof to keep the animals dry, but are open on the sides to allow free air circulation. Dairy cattle are metabolically so active, that they feel most comfortable at temperatures at around 15 degrees celsius. They struggle more with too hot temperatures than too cold ones. All animals at Crichton are kept indoors during the winter, but the high forage feeding group is turned out for grazing over the summer months. Therefore, this group is more exposed to weather such as precipitation. Weather may also indirectly influence telomere length in dairy cattle by having an impact on food quality which ay vary from year to year.
Weather data was obtained from the metoffice weather station in Eskdalemuir (Location 323400E 602600N, Lat 55.311 Lon -3.206, 242m amsl) on the 3rd of August 2020. Eskdakenuir is with 21.8 miles (35.1 km) direct distance (calculated with freemaptools) the closest weather station to the farm in Dumfries. Weather data included maximum temperature, minimum temperature, days of air frost, total rain in mm and total sun hours for each recoreded month. Data was reduced to the years of interest between 2006 and 2015 and summarised to maximise its relevance considering the sampling interval on the farm to quarterly and yearly statistics in the following way: Routine blood sampling was performed in March and therefore the calendar year was divided into quartals and then allocated to a “sample year” which ran from April the previous year to end of March of the year when the blood samples were taken. By doing this sampling intervals for weather and telomere data was synchronised.
The dataset that was used above to investigate initial change in telomere lenght within the first year of life, one sample was taken shortly after birth and a second close to the age of one year. The sampling interval for those animals was the most consistant and therefore used to test the hypothesis that environmental factors such as weather may add to the variation in telomere length dynamics during the majour growth phase of the animals.
init_weath<-merge(init_change_dat, weather, by ="sample_year")
levels(as.factor(init_change_dat$sample_year))
## [1] "2010" "2011" "2012" "2013" "2014"
year_mod <- lmer(as.numeric(paste(init_weath$ResDiff)) ~
as.factor(init_change_dat$sample_year) +
init_change_dat$TimeMeasure +
(1|init_weath$recoded_id),
na.action=na.exclude)
summary(year_mod)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## as.numeric(paste(init_weath$ResDiff)) ~ as.factor(init_change_dat$sample_year) +
## init_change_dat$TimeMeasure + (1 | init_weath$recoded_id)
##
## REML criterion at convergence: -157.1
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.1696 -0.3965 0.0367 0.4326 2.3339
##
## Random effects:
## Groups Name Variance Std.Dev.
## init_weath$recoded_id (Intercept) 0.01769 0.1330
## Residual 0.01237 0.1112
## Number of obs: 291, groups: init_weath$recoded_id, 283
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) -1.825e-01 4.121e-02 2.515e+02
## as.factor(init_change_dat$sample_year)2011 1.835e-02 2.598e-02 2.511e+02
## as.factor(init_change_dat$sample_year)2012 2.132e-02 2.770e-02 2.783e+02
## as.factor(init_change_dat$sample_year)2013 5.287e-02 4.189e-02 2.334e+02
## as.factor(init_change_dat$sample_year)2014 1.049e-01 9.273e-02 2.836e+02
## init_change_dat$TimeMeasure 2.782e-05 1.868e-05 2.744e+02
## t value Pr(>|t|)
## (Intercept) -4.428 1.42e-05 ***
## as.factor(init_change_dat$sample_year)2011 0.707 0.481
## as.factor(init_change_dat$sample_year)2012 0.770 0.442
## as.factor(init_change_dat$sample_year)2013 1.262 0.208
## as.factor(init_change_dat$sample_year)2014 1.131 0.259
## init_change_dat$TimeMeasure 1.489 0.138
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) a.(__$_)2011 a.(__$_)2012 a.(__$_)2013 a.(__$_)2014
## a.(__$_)2011 -0.428
## a.(__$_)2012 -0.513 0.539
## a.(__$_)2013 -0.624 0.371 0.410
## a.(__$_)2014 -0.352 0.180 0.206 0.228
## int_chn_$TM -0.884 0.098 0.212 0.470 0.288
anova(year_mod)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value
## as.factor(init_change_dat$sample_year) 0.029464 0.007366 4 266.20 0.5953
## init_change_dat$TimeMeasure 0.027436 0.027436 1 274.39 2.2175
## Pr(>F)
## as.factor(init_change_dat$sample_year) 0.6663
## init_change_dat$TimeMeasure 0.1376
w1 <- ggplot(init_weath,
aes(x=maxT_Q2 , y = as.numeric(paste(init_weath$ResDiff)))) +
geom_point(colour = mycoloursP[6]) +
xlab("Max summer temperature °C") +
ylab("Change in RLTL") +
geom_smooth(method = lm) +
theme_bw(15)
Change in telomere length calves seems to be not significantly associated with sample year so it is difficult to argue for an effect of weather on change in RLTL length in early life. Other environmental stressors may have a larger impact or genetics may drive this effect. Maybe the sampling intervals are not consistant enogough?
Intitial change data
plot_data<- init_change_dat
plot_data$S_date0 <-as.Date(plot_data$S_date0, "%d/%m/%Y")
plot_data$S_date1 <-as.Date(plot_data$S_date1, "%d/%m/%Y")
plot_data1 <- data.frame(sample_date = plot_data$S_date0,
recoded_id = as.factor(paste(plot_data$recoded_id)))
plot_data2 <- data.frame(sample_date = plot_data$S_date1,
recoded_id = as.factor(paste(plot_data$recoded_id)))
plot_data <- rbind(plot_data1, plot_data2)
ggplot(plot_data, aes(sample_date, recoded_id, colour = recoded_id)) +
geom_line(size = 2) +
xlab("") + ylab("") +
theme_classic() + theme(legend.position="none")
To better visualise sampling intervals for calves, the first 50 individuals (which are in randm order, because dummy IDs were given randomly) are visualised.
subboul <- plot_data$recoded_id[1:50]
sub50 <- subset(plot_data, plot_data$recoded_id %in% subboul)
ggplot(sub50, aes(sample_date, recoded_id, colour = recoded_id)) +
geom_line(size = 2) +
xlab("Sample Interval") + ylab("Calf ID") +
theme_classic() + theme(legend.position="none")
# max T per year
yTmax_mod_1 <- lmer(as.numeric(paste(redData$diff_rltl_res)) ~
redData$age_y +
redData$feed_group +
redData$genetic_group +
as.numeric(paste(redData$sample_interval)) +
redData$sampleYear_maxT +
(1|redData$recoded_id),
na.action=na.exclude)
## boundary (singular) fit: see ?isSingular
summary(yTmax_mod_1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## as.numeric(paste(redData$diff_rltl_res)) ~ redData$age_y + redData$feed_group +
## redData$genetic_group + as.numeric(paste(redData$sample_interval)) +
## redData$sampleYear_maxT + (1 | redData$recoded_id)
##
## REML criterion at convergence: -632.7
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.7678 -0.7103 0.0073 0.6666 3.2334
##
## Random effects:
## Groups Name Variance Std.Dev.
## redData$recoded_id (Intercept) 0.00000 0.0000
## Residual 0.02972 0.1724
## Number of obs: 1019, groups: redData$recoded_id, 305
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) 6.003e-02 8.485e-02 1.012e+03
## redData$age_y 3.626e-02 4.969e-03 1.012e+03
## redData$feed_group2 -1.251e-02 1.210e-02 1.012e+03
## redData$feed_groupNULL -1.136e-02 1.545e-02 1.012e+03
## redData$genetic_groupS -1.079e-02 1.136e-02 1.012e+03
## as.numeric(paste(redData$sample_interval)) 1.781e-05 5.197e-05 1.012e+03
## redData$sampleYear_maxT -9.257e-03 4.789e-03 1.012e+03
## t value Pr(>|t|)
## (Intercept) 0.707 0.4795
## redData$age_y 7.298 5.9e-13 ***
## redData$feed_group2 -1.034 0.3013
## redData$feed_groupNULL -0.735 0.4623
## redData$genetic_groupS -0.949 0.3426
## as.numeric(paste(redData$sample_interval)) 0.343 0.7319
## redData$sampleYear_maxT -1.933 0.0535 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) rdDt$_ rdD$_2 rD$_NU rdD$_S a.((D$
## redData$g_y 0.424
## rdDt$fd_gr2 -0.084 -0.086
## rdDt$f_NULL -0.012 0.092 0.375
## rdDt$gntc_S -0.015 0.071 -0.026 0.240
## as.n((D$_)) -0.069 -0.081 0.049 -0.044 0.066
## rdDt$smpY_T -0.962 -0.513 0.014 -0.058 -0.071 -0.146
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
anova(yTmax_mod_1)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value
## redData$age_y 1.58266 1.58266 1 1012 53.2584
## redData$feed_group 0.03596 0.01798 2 1012 0.6050
## redData$genetic_group 0.02679 0.02679 1 1012 0.9013
## as.numeric(paste(redData$sample_interval)) 0.00349 0.00349 1 1012 0.1175
## redData$sampleYear_maxT 0.11102 0.11102 1 1012 3.7358
## Pr(>F)
## redData$age_y 5.903e-13 ***
## redData$feed_group 0.54627
## redData$genetic_group 0.34265
## as.numeric(paste(redData$sample_interval)) 0.73188
## redData$sampleYear_maxT 0.05354 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AIC(yTmax_mod_1)
## [1] -614.7018
# min T per year
yTmin_mod_1 <- lmer(as.numeric(paste(redData$diff_rltl_res)) ~
redData$age_y +
redData$feed_group +
redData$genetic_group +
as.numeric(paste(redData$sample_interval)) +
redData$year_minT +
(1|redData$recoded_id),
na.action=na.exclude)
## boundary (singular) fit: see ?isSingular
summary(yTmin_mod_1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## as.numeric(paste(redData$diff_rltl_res)) ~ redData$age_y + redData$feed_group +
## redData$genetic_group + as.numeric(paste(redData$sample_interval)) +
## redData$year_minT + (1 | redData$recoded_id)
##
## REML criterion at convergence: -628.8
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.7570 -0.6954 0.0126 0.6688 3.2381
##
## Random effects:
## Groups Name Variance Std.Dev.
## redData$recoded_id (Intercept) 0.00000 0.0000
## Residual 0.02979 0.1726
## Number of obs: 1019, groups: redData$recoded_id, 305
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) -8.778e-02 2.490e-02 1.012e+03
## redData$age_y 2.930e-02 4.673e-03 1.012e+03
## redData$feed_group2 -1.179e-02 1.212e-02 1.012e+03
## redData$feed_groupNULL -1.270e-02 1.545e-02 1.012e+03
## redData$genetic_groupS -1.260e-02 1.135e-02 1.012e+03
## as.numeric(paste(redData$sample_interval)) 5.077e-06 5.151e-05 1.012e+03
## redData$year_minT 2.654e-03 2.461e-03 1.012e+03
## t value Pr(>|t|)
## (Intercept) -3.526 0.000442 ***
## redData$age_y 6.270 5.33e-10 ***
## redData$feed_group2 -0.973 0.330823
## redData$feed_groupNULL -0.822 0.411408
## redData$genetic_groupS -1.110 0.267389
## as.numeric(paste(redData$sample_interval)) 0.099 0.921509
## redData$year_minT 1.078 0.281244
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) rdDt$_ rdD$_2 rD$_NU rdD$_S a.((D$
## redData$g_y -0.404
## rdDt$fd_gr2 -0.228 -0.096
## rdDt$f_NULL -0.222 0.057 0.377
## rdDt$gntc_S -0.292 0.045 -0.026 0.236
## as.n((D$_)) -0.709 -0.181 0.053 -0.052 0.056
## rdDt$yr_mnT 0.373 -0.405 0.030 0.024 -0.020 0.034
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
anova(yTmin_mod_1)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value
## redData$age_y 1.17126 1.17126 1 1012 39.3143
## redData$feed_group 0.03539 0.01769 2 1012 0.5939
## redData$genetic_group 0.03669 0.03669 1 1012 1.2314
## as.numeric(paste(redData$sample_interval)) 0.00029 0.00029 1 1012 0.0097
## redData$year_minT 0.03463 0.03463 1 1012 1.1623
## Pr(>F)
## redData$age_y 5.334e-10 ***
## redData$feed_group 0.5524
## redData$genetic_group 0.2674
## as.numeric(paste(redData$sample_interval)) 0.9215
## redData$year_minT 0.2812
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AIC(yTmin_mod_1)
## [1] -610.8005
#mean days of air frost per year
ymAF_mod_1 <- lmer(as.numeric(paste(redData$diff_rltl_res)) ~
redData$age_y +
redData$feed_group +
redData$genetic_group +
as.numeric(paste(redData$sample_interval)) +
redData$sampleYear_af_days_mean +
(1|redData$recoded_id),
na.action=na.exclude)
## boundary (singular) fit: see ?isSingular
summary(ymAF_mod_1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## as.numeric(paste(redData$diff_rltl_res)) ~ redData$age_y + redData$feed_group +
## redData$genetic_group + as.numeric(paste(redData$sample_interval)) +
## redData$sampleYear_af_days_mean + (1 | redData$recoded_id)
##
## REML criterion at convergence: -628.7
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.7662 -0.7062 0.0185 0.6724 3.2211
##
## Random effects:
## Groups Name Variance Std.Dev.
## redData$recoded_id (Intercept) 0.0000 0.0000
## Residual 0.0298 0.1726
## Number of obs: 1019, groups: redData$recoded_id, 305
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) -1.174e-01 3.170e-02 1.012e+03
## redData$age_y 3.206e-02 4.348e-03 1.012e+03
## redData$feed_group2 -1.228e-02 1.211e-02 1.012e+03
## redData$feed_groupNULL -1.348e-02 1.545e-02 1.012e+03
## redData$genetic_groupS -1.224e-02 1.135e-02 1.012e+03
## as.numeric(paste(redData$sample_interval)) 2.658e-06 5.150e-05 1.012e+03
## redData$sampleYear_af_days_mean 2.490e-03 2.758e-03 1.012e+03
## t value Pr(>|t|)
## (Intercept) -3.704 0.000224 ***
## redData$age_y 7.375 3.41e-13 ***
## redData$feed_group2 -1.014 0.311040
## redData$feed_groupNULL -0.873 0.383095
## redData$genetic_groupS -1.078 0.281337
## as.numeric(paste(redData$sample_interval)) 0.052 0.958838
## redData$sampleYear_af_days_mean 0.903 0.366875
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) rdDt$_ rdD$_2 rD$_NU rdD$_S a.((D$
## redData$g_y -0.340
## rdDt$fd_gr2 -0.182 -0.092
## rdDt$f_NULL -0.162 0.066 0.377
## rdDt$gntc_S -0.231 0.041 -0.025 0.236
## as.n((D$_)) -0.559 -0.182 0.052 -0.053 0.057
## rdDt$smY___ -0.685 0.185 -0.009 -0.028 0.012 -0.011
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
anova(ymAF_mod_1)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value
## redData$age_y 1.62114 1.62114 1 1012 54.3963
## redData$feed_group 0.03898 0.01949 2 1012 0.6540
## redData$genetic_group 0.03463 0.03463 1 1012 1.1619
## as.numeric(paste(redData$sample_interval)) 0.00008 0.00008 1 1012 0.0027
## redData$sampleYear_af_days_mean 0.02429 0.02429 1 1012 0.8150
## Pr(>F)
## redData$age_y 3.406e-13 ***
## redData$feed_group 0.5202
## redData$genetic_group 0.2813
## as.numeric(paste(redData$sample_interval)) 0.9588
## redData$sampleYear_af_days_mean 0.3669
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AIC(ymAF_mod_1)
## [1] -610.6811
#max sun hours/month per year
#(n.s.)
yMaxSH_mod_1 <- lmer(as.numeric(paste(redData$diff_rltl_res)) ~
redData$age_y +
redData$feed_group +
redData$genetic_group +
as.numeric(paste(redData$sample_interval)) +
redData$sampleYear_sun_hours_max +
(1|redData$recoded_id),
na.action=na.exclude)
## boundary (singular) fit: see ?isSingular
summary(yMaxSH_mod_1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## as.numeric(paste(redData$diff_rltl_res)) ~ redData$age_y + redData$feed_group +
## redData$genetic_group + as.numeric(paste(redData$sample_interval)) +
## redData$sampleYear_sun_hours_max + (1 | redData$recoded_id)
##
## REML criterion at convergence: -626.7
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.7471 -0.6850 0.0149 0.6663 3.2573
##
## Random effects:
## Groups Name Variance Std.Dev.
## redData$recoded_id (Intercept) 0.00000 0.0000
## Residual 0.02973 0.1724
## Number of obs: 1019, groups: redData$recoded_id, 305
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) -1.928e-01 5.749e-02 1.012e+03
## redData$age_y 2.859e-02 4.531e-03 1.012e+03
## redData$feed_group2 -1.152e-02 1.210e-02 1.012e+03
## redData$feed_groupNULL -1.225e-02 1.544e-02 1.012e+03
## redData$genetic_groupS -1.250e-02 1.134e-02 1.012e+03
## as.numeric(paste(redData$sample_interval)) 9.027e-06 5.153e-05 1.012e+03
## redData$sampleYear_sun_hours_max 5.556e-04 3.079e-04 1.012e+03
## t value Pr(>|t|)
## (Intercept) -3.354 0.000827 ***
## redData$age_y 6.310 4.17e-10 ***
## redData$feed_group2 -0.952 0.341422
## redData$feed_groupNULL -0.794 0.427428
## redData$genetic_groupS -1.102 0.270608
## as.numeric(paste(redData$sample_interval)) 0.175 0.860981
## redData$sampleYear_sun_hours_max 1.804 0.071490 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) rdDt$_ rdD$_2 rD$_NU rdD$_S a.((D$
## redData$g_y 0.195
## rdDt$fd_gr2 -0.131 -0.096
## rdDt$f_NULL -0.127 0.058 0.377
## rdDt$gntc_S -0.117 0.040 -0.025 0.236
## as.n((D$_)) -0.369 -0.193 0.054 -0.051 0.056
## rdDt$smY___ -0.916 -0.336 0.030 0.030 -0.007 0.063
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
anova(yMaxSH_mod_1)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value
## redData$age_y 1.18371 1.18371 1 1012 39.8142
## redData$feed_group 0.03349 0.01674 2 1012 0.5632
## redData$genetic_group 0.03612 0.03612 1 1012 1.2150
## as.numeric(paste(redData$sample_interval)) 0.00091 0.00091 1 1012 0.0307
## redData$sampleYear_sun_hours_max 0.09678 0.09678 1 1012 3.2553
## Pr(>F)
## redData$age_y 4.17e-10 ***
## redData$feed_group 0.56955
## redData$genetic_group 0.27061
## as.numeric(paste(redData$sample_interval)) 0.86098
## redData$sampleYear_sun_hours_max 0.07149 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AIC(yMaxSH_mod_1)
## [1] -608.7338
#mean precipitation per year
#(n.s.)
y_rain <- lmer(as.numeric(paste(redData$diff_rltl_res)) ~
redData$age_y +
redData$feed_group +
redData$genetic_group +
as.numeric(paste(redData$sample_interval)) +
redData$sampleYear_mean_rain +
(1|redData$recoded_id),
na.action=na.exclude)
## boundary (singular) fit: see ?isSingular
summary(y_rain)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## as.numeric(paste(redData$diff_rltl_res)) ~ redData$age_y + redData$feed_group +
## redData$genetic_group + as.numeric(paste(redData$sample_interval)) +
## redData$sampleYear_mean_rain + (1 | redData$recoded_id)
##
## REML criterion at convergence: -623.2
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.7658 -0.7120 0.0134 0.6762 3.2228
##
## Random effects:
## Groups Name Variance Std.Dev.
## redData$recoded_id (Intercept) 0.00000 0.0000
## Residual 0.02981 0.1727
## Number of obs: 1019, groups: redData$recoded_id, 305
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) -8.982e-02 2.606e-02 1.012e+03
## redData$age_y 3.363e-02 5.496e-03 1.012e+03
## redData$feed_group2 -1.243e-02 1.212e-02 1.012e+03
## redData$feed_groupNULL -1.257e-02 1.547e-02 1.012e+03
## redData$genetic_groupS -1.178e-02 1.139e-02 1.012e+03
## as.numeric(paste(redData$sample_interval)) 7.285e-06 5.188e-05 1.012e+03
## redData$sampleYear_mean_rain -1.416e-04 2.139e-04 1.012e+03
## t value Pr(>|t|)
## (Intercept) -3.447 0.000591 ***
## redData$age_y 6.119 1.35e-09 ***
## redData$feed_group2 -1.026 0.305203
## redData$feed_groupNULL -0.812 0.416839
## redData$genetic_groupS -1.034 0.301394
## as.numeric(paste(redData$sample_interval)) 0.140 0.888352
## redData$sampleYear_mean_rain -0.662 0.508058
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) rdDt$_ rdD$_2 rD$_NU rdD$_S a.((D$
## redData$g_y 0.086
## rdDt$fd_gr2 -0.244 -0.091
## rdDt$f_NULL -0.197 0.089 0.374
## rdDt$gntc_S -0.235 0.079 -0.028 0.240
## as.n((D$_)) -0.630 -0.066 0.048 -0.047 0.065
## rdDt$smpY__ -0.462 -0.629 0.032 -0.052 -0.077 -0.120
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
anova(y_rain)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value
## redData$age_y 1.11625 1.11625 1 1012 37.4410
## redData$feed_group 0.03773 0.01887 2 1012 0.6328
## redData$genetic_group 0.03187 0.03187 1 1012 1.0691
## as.numeric(paste(redData$sample_interval)) 0.00059 0.00059 1 1012 0.0197
## redData$sampleYear_mean_rain 0.01307 0.01307 1 1012 0.4384
## Pr(>F)
## redData$age_y 1.345e-09 ***
## redData$feed_group 0.5313
## redData$genetic_group 0.3014
## as.numeric(paste(redData$sample_interval)) 0.8884
## redData$sampleYear_mean_rain 0.5081
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AIC(y_rain)
## [1] -605.1902
max temperature
#maxT spring
#
yMaxSH_mod_1 <- lmer(as.numeric(paste(redData$diff_rltl_res)) ~
redData$age_y +
redData$feed_group +
redData$genetic_group +
as.numeric(paste(redData$sample_interval)) +
redData$maxT_Q1 +
(1|redData$recoded_id),
na.action=na.exclude)
## boundary (singular) fit: see ?isSingular
summary(yMaxSH_mod_1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## as.numeric(paste(redData$diff_rltl_res)) ~ redData$age_y + redData$feed_group +
## redData$genetic_group + as.numeric(paste(redData$sample_interval)) +
## redData$maxT_Q1 + (1 | redData$recoded_id)
##
## REML criterion at convergence: -628.8
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.7673 -0.7049 0.0199 0.6740 3.2206
##
## Random effects:
## Groups Name Variance Std.Dev.
## redData$recoded_id (Intercept) 0.00000 0.0000
## Residual 0.02979 0.1726
## Number of obs: 1019, groups: redData$recoded_id, 305
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) -7.302e-02 3.210e-02 1.012e+03
## redData$age_y 3.070e-02 4.310e-03 1.012e+03
## redData$feed_group2 -1.211e-02 1.211e-02 1.012e+03
## redData$feed_groupNULL -1.395e-02 1.546e-02 1.012e+03
## redData$genetic_groupS -1.257e-02 1.135e-02 1.012e+03
## as.numeric(paste(redData$sample_interval)) 2.179e-07 5.155e-05 1.012e+03
## redData$maxT_Q1 -2.644e-03 2.379e-03 1.012e+03
## t value Pr(>|t|)
## (Intercept) -2.275 0.0231 *
## redData$age_y 7.125 1.98e-12 ***
## redData$feed_group2 -1.000 0.3177
## redData$feed_groupNULL -0.902 0.3671
## redData$genetic_groupS -1.107 0.2685
## as.numeric(paste(redData$sample_interval)) 0.004 0.9966
## redData$maxT_Q1 -1.111 0.2666
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) rdDt$_ rdD$_2 rD$_NU rdD$_S a.((D$
## redData$g_y -0.304
## rdDt$fd_gr2 -0.182 -0.092
## rdDt$f_NULL -0.214 0.078 0.376
## rdDt$gntc_S -0.232 0.042 -0.025 0.237
## as.n((D$_)) -0.595 -0.174 0.052 -0.050 0.058
## rdDt$mxT_Q1 -0.694 0.132 -0.005 0.050 0.017 0.052
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
anova(yMaxSH_mod_1)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value
## redData$age_y 1.51216 1.51216 1 1012 50.7605
## redData$feed_group 0.03938 0.01969 2 1012 0.6610
## redData$genetic_group 0.03652 0.03652 1 1012 1.2260
## as.numeric(paste(redData$sample_interval)) 0.00000 0.00000 1 1012 0.0000
## redData$maxT_Q1 0.03680 0.03680 1 1012 1.2353
## Pr(>F)
## redData$age_y 1.98e-12 ***
## redData$feed_group 0.5165
## redData$genetic_group 0.2685
## as.numeric(paste(redData$sample_interval)) 0.9966
## redData$maxT_Q1 0.2666
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AIC(yMaxSH_mod_1)
## [1] -610.8054
#maxT summer
#(s!)
yMaxSuH_mod_1 <- lmer(as.numeric(paste(redData$diff_rltl_res)) ~
redData$age_y +
redData$feed_group +
redData$genetic_group +
as.numeric(paste(redData$sample_interval)) +
redData$maxT_Q2 +
(1|redData$recoded_id),
na.action=na.exclude)
## boundary (singular) fit: see ?isSingular
summary(yMaxSuH_mod_1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## as.numeric(paste(redData$diff_rltl_res)) ~ redData$age_y + redData$feed_group +
## redData$genetic_group + as.numeric(paste(redData$sample_interval)) +
## redData$maxT_Q2 + (1 | redData$recoded_id)
##
## REML criterion at convergence: -639.1
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.6889 -0.6678 0.0205 0.6675 3.3379
##
## Random effects:
## Groups Name Variance Std.Dev.
## redData$recoded_id (Intercept) 0.00000 0.0000
## Residual 0.02951 0.1718
## Number of obs: 1019, groups: redData$recoded_id, 305
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) 9.270e-02 6.248e-02 1.012e+03
## redData$age_y 2.812e-02 4.364e-03 1.012e+03
## redData$feed_group2 -1.099e-02 1.206e-02 1.012e+03
## redData$feed_groupNULL -1.239e-02 1.537e-02 1.012e+03
## redData$genetic_groupS -1.206e-02 1.130e-02 1.012e+03
## as.numeric(paste(redData$sample_interval)) 1.676e-05 5.141e-05 1.012e+03
## redData$maxT_Q2 -1.156e-02 3.525e-03 1.012e+03
## t value Pr(>|t|)
## (Intercept) 1.484 0.13821
## redData$age_y 6.444 1.79e-10 ***
## redData$feed_group2 -0.911 0.36235
## redData$feed_groupNULL -0.806 0.42035
## redData$genetic_groupS -1.068 0.28584
## as.numeric(paste(redData$sample_interval)) 0.326 0.74451
## redData$maxT_Q2 -3.279 0.00108 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) rdDt$_ rdD$_2 rD$_NU rdD$_S a.((D$
## redData$g_y -0.316
## rdDt$fd_gr2 -0.067 -0.096
## rdDt$f_NULL -0.079 0.068 0.377
## rdDt$gntc_S -0.105 0.037 -0.025 0.237
## as.n((D$_)) -0.210 -0.196 0.054 -0.052 0.057
## rdDt$mxT_Q2 -0.930 0.225 -0.030 -0.014 -0.008 -0.081
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
anova(yMaxSuH_mod_1)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value
## redData$age_y 1.22567 1.22567 1 1012 41.5301
## redData$feed_group 0.03187 0.01594 2 1012 0.5400
## redData$genetic_group 0.03365 0.03365 1 1012 1.1403
## as.numeric(paste(redData$sample_interval)) 0.00314 0.00314 1 1012 0.1063
## redData$maxT_Q2 0.31728 0.31728 1 1012 10.7507
## Pr(>F)
## redData$age_y 1.793e-10 ***
## redData$feed_group 0.582909
## redData$genetic_group 0.285844
## as.numeric(paste(redData$sample_interval)) 0.744511
## redData$maxT_Q2 0.001078 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AIC(yMaxSuH_mod_1)
## [1] -621.0605
w2 <- ggplot(redData,
aes(x=maxT_Q2 , y = as.numeric(paste(redData$diff_rltl_res)))) +
geom_point(colour = mycoloursP[6]) +
xlab("Max summer temperature in °C") +
ylab("Change in RLTL") +
geom_smooth(method = lm) +
theme_bw(15)
grid.arrange(w1, w2, ncol = 2)
## Warning: Use of `init_weath$ResDiff` is discouraged. Use `ResDiff` instead.
## Warning: Use of `init_weath$ResDiff` is discouraged. Use `ResDiff` instead.
## `geom_smooth()` using formula 'y ~ x'
## Warning: Use of `redData$diff_rltl_res` is discouraged. Use `diff_rltl_res`
## instead.
## Warning: Use of `redData$diff_rltl_res` is discouraged. Use `diff_rltl_res`
## instead.
## `geom_smooth()` using formula 'y ~ x'
#first plot is relationship between summer temperature and RLTL change in calves, second in adults.
sam_year<- as.factor(redData$sample_year)
tel_change<-as.numeric(paste(redData$diff_rltl_res))
ggplot(redData, aes(x=maxT_Q2, y = tel_change)) +
xlab("Max summer temperature in °C") +
ylab("Change in RLTL") + theme_bw(15) +
geom_point(colour = sam_year) +
scale_colour_manual(values = mycoloursP) +
geom_smooth(method = lm, formula = y~x)
fig2 <- ggplot(redData, aes(x=maxT_Q2, y = tel_change)) +
xlab("Max summer temperature in °C") +
ylab("Change in RLTL") +
theme_bw(15) +
geom_point(aes(colour = sam_year)) +
scale_colour_manual(values = mycoloursP) +
geom_smooth(method = lm, formula = y~x)
fig2
tableS8 <- as.data.frame(round(coef(summary(yMaxSuH_mod_1)),3))
tableS8
## Estimate Std. Error df t value
## (Intercept) 0.093 0.062 1012 1.484
## redData$age_y 0.028 0.004 1012 6.444
## redData$feed_group2 -0.011 0.012 1012 -0.911
## redData$feed_groupNULL -0.012 0.015 1012 -0.806
## redData$genetic_groupS -0.012 0.011 1012 -1.068
## as.numeric(paste(redData$sample_interval)) 0.000 0.000 1012 0.326
## redData$maxT_Q2 -0.012 0.004 1012 -3.279
## Pr(>|t|)
## (Intercept) 0.138
## redData$age_y 0.000
## redData$feed_group2 0.362
## redData$feed_groupNULL 0.420
## redData$genetic_groupS 0.286
## as.numeric(paste(redData$sample_interval)) 0.745
## redData$maxT_Q2 0.001
tableS9 <- as.data.frame(anova(yMaxSuH_mod_1))
tableS9
## Sum Sq Mean Sq NumDF DenDF
## redData$age_y 1.225671033 1.225671033 1 1012
## redData$feed_group 0.031874615 0.015937307 2 1012
## redData$genetic_group 0.033653414 0.033653414 1 1012
## as.numeric(paste(redData$sample_interval)) 0.003136009 0.003136009 1 1012
## redData$maxT_Q2 0.317284236 0.317284236 1 1012
## F value Pr(>F)
## redData$age_y 41.5300668 1.792671e-10
## redData$feed_group 0.5400123 5.829089e-01
## redData$genetic_group 1.1402966 2.858443e-01
## as.numeric(paste(redData$sample_interval)) 0.1062591 7.445114e-01
## redData$maxT_Q2 10.7507114 1.077901e-03
### does sample year remain significant with max temp in the model?
yMaxSuH_year <- lmer(as.numeric(paste(redData$diff_rltl_res)) ~
redData$age_y +
redData$feed_group +
redData$genetic_group +
as.numeric(paste(redData$sample_interval)) +
redData$sample_year +
redData$maxT_Q2 +
(1|redData$recoded_id),
na.action=na.exclude)
## boundary (singular) fit: see ?isSingular
summary(yMaxSuH_year)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## as.numeric(paste(redData$diff_rltl_res)) ~ redData$age_y + redData$feed_group +
## redData$genetic_group + as.numeric(paste(redData$sample_interval)) +
## redData$sample_year + redData$maxT_Q2 + (1 | redData$recoded_id)
##
## REML criterion at convergence: -631.6
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.6483 -0.6649 0.0158 0.6766 3.3750
##
## Random effects:
## Groups Name Variance Std.Dev.
## redData$recoded_id (Intercept) 5.674e-18 2.382e-09
## Residual 2.952e-02 1.718e-01
## Number of obs: 1019, groups: redData$recoded_id, 305
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) -1.105e+01 1.379e+01 1.011e+03
## redData$age_y 2.479e-02 6.004e-03 1.011e+03
## redData$feed_group2 -1.056e-02 1.207e-02 1.011e+03
## redData$feed_groupNULL -1.362e-02 1.545e-02 1.011e+03
## redData$genetic_groupS -1.289e-02 1.135e-02 1.011e+03
## as.numeric(paste(redData$sample_interval)) 1.038e-05 5.202e-05 1.011e+03
## redData$sample_year 5.528e-03 6.844e-03 1.011e+03
## redData$maxT_Q2 -1.006e-02 3.986e-03 1.011e+03
## t value Pr(>|t|)
## (Intercept) -0.801 0.4233
## redData$age_y 4.129 3.95e-05 ***
## redData$feed_group2 -0.875 0.3820
## redData$feed_groupNULL -0.881 0.3783
## redData$genetic_groupS -1.136 0.2561
## as.numeric(paste(redData$sample_interval)) 0.200 0.8419
## redData$sample_year 0.808 0.4194
## redData$maxT_Q2 -2.523 0.0118 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) rdDt$g_ rdD$_2 rD$_NU rdD$_S a.((D$ rdDt$s_
## redData$g_y 0.686
## rdDt$fd_gr2 -0.045 -0.100
## rdDt$f_NULL 0.098 0.116 0.370
## rdDt$gntc_S 0.090 0.089 -0.029 0.243
## as.n((D$_)) 0.151 -0.036 0.047 -0.036 0.070
## rdDt$smpl_y -1.000 -0.687 0.044 -0.098 -0.090 -0.152
## rdDt$mxT_Q2 -0.470 -0.176 -0.006 -0.058 -0.049 -0.141 0.466
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
anova(yMaxSuH_year)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value
## redData$age_y 0.50322 0.50322 1 1011 17.0450
## redData$feed_group 0.03321 0.01661 2 1011 0.5625
## redData$genetic_group 0.03812 0.03812 1 1011 1.2911
## as.numeric(paste(redData$sample_interval)) 0.00118 0.00118 1 1011 0.0398
## redData$sample_year 0.01926 0.01926 1 1011 0.6524
## redData$maxT_Q2 0.18793 0.18793 1 1011 6.3654
## Pr(>F)
## redData$age_y 3.951e-05 ***
## redData$feed_group 0.56997
## redData$genetic_group 0.25611
## as.numeric(paste(redData$sample_interval)) 0.84187
## redData$sample_year 0.41944
## redData$maxT_Q2 0.01179 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AIC(yMaxSuH_year)
## [1] -611.582
tableS10<-as.data.frame(round(coef(summary(yMaxSuH_year)),3))
tableS10
## Estimate Std. Error df t value
## (Intercept) -11.045 13.790 1011 -0.801
## redData$age_y 0.025 0.006 1011 4.129
## redData$feed_group2 -0.011 0.012 1011 -0.875
## redData$feed_groupNULL -0.014 0.015 1011 -0.881
## redData$genetic_groupS -0.013 0.011 1011 -1.136
## as.numeric(paste(redData$sample_interval)) 0.000 0.000 1011 0.200
## redData$sample_year 0.006 0.007 1011 0.808
## redData$maxT_Q2 -0.010 0.004 1011 -2.523
## Pr(>|t|)
## (Intercept) 0.423
## redData$age_y 0.000
## redData$feed_group2 0.382
## redData$feed_groupNULL 0.378
## redData$genetic_groupS 0.256
## as.numeric(paste(redData$sample_interval)) 0.842
## redData$sample_year 0.419
## redData$maxT_Q2 0.012
tableS11<-as.data.frame(anova(yMaxSuH_year))
tableS11
## Sum Sq Mean Sq NumDF DenDF
## redData$age_y 0.503220727 0.503220727 1 1011
## redData$feed_group 0.033212450 0.016606225 2 1011
## redData$genetic_group 0.038117823 0.038117823 1 1011
## as.numeric(paste(redData$sample_interval)) 0.001175651 0.001175651 1 1011
## redData$sample_year 0.019261360 0.019261360 1 1011
## redData$maxT_Q2 0.187925890 0.187925890 1 1011
## F value Pr(>F)
## redData$age_y 17.04504060 3.951376e-05
## redData$feed_group 0.56248434 5.699700e-01
## redData$genetic_group 1.29112296 2.561104e-01
## as.numeric(paste(redData$sample_interval)) 0.03982152 8.418701e-01
## redData$sample_year 0.65241880 4.194392e-01
## redData$maxT_Q2 6.36540636 1.178909e-02
### no sample year becomes nor significant, but max temp in summer remains significant
#maxT autumn
#(n.s.)
yMaxAH_mod_1 <- lmer(as.numeric(paste(redData$diff_rltl_res)) ~
redData$age_y +
redData$feed_group +
redData$genetic_group +
as.numeric(paste(redData$sample_interval)) +
redData$maxT_Q3 +
(1|redData$recoded_id),
na.action=na.exclude)
## boundary (singular) fit: see ?isSingular
summary(yMaxAH_mod_1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## as.numeric(paste(redData$diff_rltl_res)) ~ redData$age_y + redData$feed_group +
## redData$genetic_group + as.numeric(paste(redData$sample_interval)) +
## redData$maxT_Q3 + (1 | redData$recoded_id)
##
## REML criterion at convergence: -631.2
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.7478 -0.6997 0.0182 0.6674 3.2463
##
## Random effects:
## Groups Name Variance Std.Dev.
## redData$recoded_id (Intercept) 0.00000 0.0000
## Residual 0.02976 0.1725
## Number of obs: 1019, groups: redData$recoded_id, 305
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) 1.767e-02 7.954e-02 1.012e+03
## redData$age_y 3.586e-02 5.207e-03 1.012e+03
## redData$feed_group2 -1.258e-02 1.211e-02 1.012e+03
## redData$feed_groupNULL -1.205e-02 1.545e-02 1.012e+03
## redData$genetic_groupS -1.109e-02 1.137e-02 1.012e+03
## as.numeric(paste(redData$sample_interval)) 1.309e-05 5.187e-05 1.012e+03
## redData$maxT_Q3 -6.949e-03 4.580e-03 1.012e+03
## t value Pr(>|t|)
## (Intercept) 0.222 0.824
## redData$age_y 6.887 9.98e-12 ***
## redData$feed_group2 -1.039 0.299
## redData$feed_groupNULL -0.780 0.436
## redData$genetic_groupS -0.975 0.330
## as.numeric(paste(redData$sample_interval)) 0.252 0.801
## redData$maxT_Q3 -1.517 0.130
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) rdDt$_ rdD$_2 rD$_NU rdD$_S a.((D$
## redData$g_y 0.477
## rdDt$fd_gr2 -0.096 -0.088
## rdDt$f_NULL -0.030 0.085 0.375
## rdDt$gntc_S -0.019 0.075 -0.027 0.239
## as.n((D$_)) -0.103 -0.077 0.049 -0.047 0.065
## rdDt$mxT_Q3 -0.957 -0.572 0.022 -0.044 -0.073 -0.126
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
anova(yMaxAH_mod_1)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value
## redData$age_y 1.41154 1.41154 1 1012 47.4329
## redData$feed_group 0.03740 0.01870 2 1012 0.6283
## redData$genetic_group 0.02830 0.02830 1 1012 0.9510
## as.numeric(paste(redData$sample_interval)) 0.00189 0.00189 1 1012 0.0636
## redData$maxT_Q3 0.06849 0.06849 1 1012 2.3015
## Pr(>F)
## redData$age_y 9.982e-12 ***
## redData$feed_group 0.5337
## redData$genetic_group 0.3297
## as.numeric(paste(redData$sample_interval)) 0.8009
## redData$maxT_Q3 0.1296
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AIC(yMaxAH_mod_1)
## [1] -613.1811
#maxT winter
#(n.s.)
yMaxW_mod_1 <- lmer(as.numeric(paste(redData$diff_rltl_res)) ~
redData$age_y +
redData$feed_group +
redData$genetic_group +
as.numeric(paste(redData$sample_interval)) +
redData$maxT_Q4 +
(1|redData$recoded_id),
na.action=na.exclude)
## boundary (singular) fit: see ?isSingular
summary(yMaxW_mod_1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## as.numeric(paste(redData$diff_rltl_res)) ~ redData$age_y + redData$feed_group +
## redData$genetic_group + as.numeric(paste(redData$sample_interval)) +
## redData$maxT_Q4 + (1 | redData$recoded_id)
##
## REML criterion at convergence: -636
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.6972 -0.6907 0.0278 0.6689 3.3046
##
## Random effects:
## Groups Name Variance Std.Dev.
## redData$recoded_id (Intercept) 0.00000 0.0000
## Residual 0.02963 0.1721
## Number of obs: 1019, groups: redData$recoded_id, 305
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) 6.878e-02 6.782e-02 1.012e+03
## redData$age_y 3.160e-02 4.261e-03 1.012e+03
## redData$feed_group2 -1.188e-02 1.208e-02 1.012e+03
## redData$feed_groupNULL -1.435e-02 1.541e-02 1.012e+03
## redData$genetic_groupS -1.204e-02 1.132e-02 1.012e+03
## as.numeric(paste(redData$sample_interval)) 5.668e-06 5.135e-05 1.012e+03
## redData$maxT_Q4 -1.435e-02 5.495e-03 1.012e+03
## t value Pr(>|t|)
## (Intercept) 1.014 0.31069
## redData$age_y 7.416 2.55e-13 ***
## redData$feed_group2 -0.984 0.32536
## redData$feed_groupNULL -0.931 0.35209
## redData$genetic_groupS -1.063 0.28785
## as.numeric(paste(redData$sample_interval)) 0.110 0.91213
## redData$maxT_Q4 -2.612 0.00914 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) rdDt$_ rdD$_2 rD$_NU rdD$_S a.((D$
## redData$g_y -0.079
## rdDt$fd_gr2 -0.079 -0.091
## rdDt$f_NULL -0.114 0.072 0.376
## rdDt$gntc_S -0.094 0.040 -0.025 0.236
## as.n((D$_)) -0.247 -0.182 0.052 -0.054 0.057
## rdDt$mxT_Q4 -0.941 -0.023 -0.009 0.031 -0.011 -0.019
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
anova(yMaxW_mod_1)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value
## redData$age_y 1.62936 1.62936 1 1012 54.9964
## redData$feed_group 0.03954 0.01977 2 1012 0.6673
## redData$genetic_group 0.03350 0.03350 1 1012 1.1309
## as.numeric(paste(redData$sample_interval)) 0.00036 0.00036 1 1012 0.0122
## redData$maxT_Q4 0.20207 0.20207 1 1012 6.8207
## Pr(>F)
## redData$age_y 2.55e-13 ***
## redData$feed_group 0.513322
## redData$genetic_group 0.287846
## as.numeric(paste(redData$sample_interval)) 0.912129
## redData$maxT_Q4 0.009144 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AIC(yMaxW_mod_1)
## [1] -618.0486
tableS12 <- as.data.frame(round(coef(summary(yMaxW_mod_1)),3))
tableS12
## Estimate Std. Error df t value
## (Intercept) 0.069 0.068 1012 1.014
## redData$age_y 0.032 0.004 1012 7.416
## redData$feed_group2 -0.012 0.012 1012 -0.984
## redData$feed_groupNULL -0.014 0.015 1012 -0.931
## redData$genetic_groupS -0.012 0.011 1012 -1.063
## as.numeric(paste(redData$sample_interval)) 0.000 0.000 1012 0.110
## redData$maxT_Q4 -0.014 0.005 1012 -2.612
## Pr(>|t|)
## (Intercept) 0.311
## redData$age_y 0.000
## redData$feed_group2 0.325
## redData$feed_groupNULL 0.352
## redData$genetic_groupS 0.288
## as.numeric(paste(redData$sample_interval)) 0.912
## redData$maxT_Q4 0.009
tableS13 <- as.data.frame(anova(yMaxW_mod_1))
tableS13
## Sum Sq Mean Sq NumDF
## redData$age_y 1.6293623875 1.6293623875 1
## redData$feed_group 0.0395392949 0.0197696475 2
## redData$genetic_group 0.0335036341 0.0335036341 1
## as.numeric(paste(redData$sample_interval)) 0.0003609755 0.0003609755 1
## redData$maxT_Q4 0.2020734344 0.2020734344 1
## DenDF F value Pr(>F)
## redData$age_y 1012 54.99641029 2.549685e-13
## redData$feed_group 1012 0.66729148 5.133220e-01
## redData$genetic_group 1012 1.13085930 2.878458e-01
## as.numeric(paste(redData$sample_interval)) 1012 0.01218413 9.121285e-01
## redData$maxT_Q4 1012 6.82065180 9.144354e-03
# max T of summer and winter quarter in the same model
yMaxSW_mod_1 <- lmer(as.numeric(paste(redData$diff_rltl_res)) ~
redData$age_y +
redData$feed_group +
redData$genetic_group +
as.numeric(paste(redData$sample_interval)) +
redData$maxT_Q4 +
redData$maxT_Q2 +
(1|redData$recoded_id),
na.action=na.exclude)
## boundary (singular) fit: see ?isSingular
summary(yMaxSW_mod_1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## as.numeric(paste(redData$diff_rltl_res)) ~ redData$age_y + redData$feed_group +
## redData$genetic_group + as.numeric(paste(redData$sample_interval)) +
## redData$maxT_Q4 + redData$maxT_Q2 + (1 | redData$recoded_id)
##
## REML criterion at convergence: -632.1
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.6694 -0.6685 0.0223 0.6689 3.3536
##
## Random effects:
## Groups Name Variance Std.Dev.
## redData$recoded_id (Intercept) 0.0000 0.0000
## Residual 0.0295 0.1718
## Number of obs: 1019, groups: redData$recoded_id, 305
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) 1.401e-01 7.446e-02 1.011e+03
## redData$age_y 2.889e-02 4.412e-03 1.011e+03
## redData$feed_group2 -1.107e-02 1.206e-02 1.011e+03
## redData$feed_groupNULL -1.317e-02 1.539e-02 1.011e+03
## redData$genetic_groupS -1.196e-02 1.130e-02 1.011e+03
## as.numeric(paste(redData$sample_interval)) 1.534e-05 5.141e-05 1.011e+03
## redData$maxT_Q4 -7.346e-03 6.275e-03 1.011e+03
## redData$maxT_Q2 -9.262e-03 4.033e-03 1.011e+03
## t value Pr(>|t|)
## (Intercept) 1.882 0.0601 .
## redData$age_y 6.548 9.25e-11 ***
## redData$feed_group2 -0.919 0.3586
## redData$feed_groupNULL -0.856 0.3921
## redData$genetic_groupS -1.059 0.2900
## as.numeric(paste(redData$sample_interval)) 0.298 0.7655
## redData$maxT_Q4 -1.171 0.2420
## redData$maxT_Q2 -2.297 0.0218 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) rdDt$_ rdD$_2 rD$_NU rdD$_S a.((D$ rD$T_Q4
## redData$g_y -0.181
## rdDt$fd_gr2 -0.060 -0.096
## rdDt$f_NULL -0.089 0.060 0.377
## rdDt$gntc_S -0.084 0.038 -0.025 0.236
## as.n((D$_)) -0.189 -0.197 0.054 -0.051 0.057
## rdDt$mxT_Q4 -0.544 -0.150 0.006 0.043 -0.008 0.024
## rdDt$mxT_Q2 -0.417 0.267 -0.029 -0.033 -0.003 -0.082 -0.486
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
anova(yMaxSW_mod_1)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value
## redData$age_y 1.26500 1.26500 1 1011 42.8784
## redData$feed_group 0.03384 0.01692 2 1011 0.5735
## redData$genetic_group 0.03307 0.03307 1 1011 1.1208
## as.numeric(paste(redData$sample_interval)) 0.00263 0.00263 1 1011 0.0890
## redData$maxT_Q4 0.04043 0.04043 1 1011 1.3705
## redData$maxT_Q2 0.15564 0.15564 1 1011 5.2756
## Pr(>F)
## redData$age_y 9.253e-11 ***
## redData$feed_group 0.56374
## redData$genetic_group 0.28999
## as.numeric(paste(redData$sample_interval)) 0.76552
## redData$maxT_Q4 0.24201
## redData$maxT_Q2 0.02183 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AIC(yMaxSW_mod_1)
## [1] -612.1264
tableS14 <- as.data.frame(round(coef(summary(yMaxSW_mod_1)),3))
tableS14
## Estimate Std. Error df t value
## (Intercept) 0.140 0.074 1011 1.882
## redData$age_y 0.029 0.004 1011 6.548
## redData$feed_group2 -0.011 0.012 1011 -0.919
## redData$feed_groupNULL -0.013 0.015 1011 -0.856
## redData$genetic_groupS -0.012 0.011 1011 -1.059
## as.numeric(paste(redData$sample_interval)) 0.000 0.000 1011 0.298
## redData$maxT_Q4 -0.007 0.006 1011 -1.171
## redData$maxT_Q2 -0.009 0.004 1011 -2.297
## Pr(>|t|)
## (Intercept) 0.060
## redData$age_y 0.000
## redData$feed_group2 0.359
## redData$feed_groupNULL 0.392
## redData$genetic_groupS 0.290
## as.numeric(paste(redData$sample_interval)) 0.766
## redData$maxT_Q4 0.242
## redData$maxT_Q2 0.022
tableS15 <- as.data.frame(anova(yMaxSW_mod_1))
tableS15
## Sum Sq Mean Sq NumDF DenDF
## redData$age_y 1.265000805 1.265000805 1 1011
## redData$feed_group 0.033838617 0.016919308 2 1011
## redData$genetic_group 0.033067026 0.033067026 1 1011
## as.numeric(paste(redData$sample_interval)) 0.002625466 0.002625466 1 1011
## redData$maxT_Q4 0.040431558 0.040431558 1 1011
## redData$maxT_Q2 0.155642360 0.155642360 1 1011
## F value Pr(>F)
## redData$age_y 42.87838932 9.252635e-11
## redData$feed_group 0.57349583 5.637351e-01
## redData$genetic_group 1.12083786 2.899910e-01
## as.numeric(paste(redData$sample_interval)) 0.08899265 7.655230e-01
## redData$maxT_Q4 1.37046560 2.420078e-01
## redData$maxT_Q2 5.27564384 2.182947e-02
# same as above plus sample year
yMaxSW_year <- lmer(as.numeric(paste(redData$diff_rltl_res)) ~
redData$age_y +
redData$feed_group +
redData$genetic_group +
as.numeric(paste(redData$sample_interval)) +
redData$maxT_Q4 +
redData$maxT_Q2 +
redData$sample_year +
(1|redData$recoded_id), na.action=na.exclude)
## boundary (singular) fit: see ?isSingular
summary(yMaxSW_year)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## as.numeric(paste(redData$diff_rltl_res)) ~ redData$age_y + redData$feed_group +
## redData$genetic_group + as.numeric(paste(redData$sample_interval)) +
## redData$maxT_Q4 + redData$maxT_Q2 + redData$sample_year +
## (1 | redData$recoded_id)
##
## REML criterion at convergence: -625
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.6172 -0.6784 0.0262 0.6816 3.4022
##
## Random effects:
## Groups Name Variance Std.Dev.
## redData$recoded_id (Intercept) 0.0000 0.0000
## Residual 0.0295 0.1718
## Number of obs: 1019, groups: redData$recoded_id, 305
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) -1.369e+01 1.393e+01 1.010e+03
## redData$age_y 2.485e-02 6.003e-03 1.010e+03
## redData$feed_group2 -1.055e-02 1.207e-02 1.010e+03
## redData$feed_groupNULL -1.479e-02 1.547e-02 1.010e+03
## redData$genetic_groupS -1.297e-02 1.134e-02 1.010e+03
## as.numeric(paste(redData$sample_interval)) 7.235e-06 5.206e-05 1.010e+03
## redData$maxT_Q4 -8.280e-03 6.345e-03 1.010e+03
## redData$maxT_Q2 -7.105e-03 4.581e-03 1.010e+03
## redData$sample_year 6.867e-03 6.918e-03 1.010e+03
## t value Pr(>|t|)
## (Intercept) -0.983 0.326
## redData$age_y 4.141 3.75e-05 ***
## redData$feed_group2 -0.874 0.382
## redData$feed_groupNULL -0.956 0.339
## redData$genetic_groupS -1.144 0.253
## as.numeric(paste(redData$sample_interval)) 0.139 0.889
## redData$maxT_Q4 -1.305 0.192
## redData$maxT_Q2 -1.551 0.121
## redData$sample_year 0.993 0.321
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) rdDt$g_ rdD$_2 rD$_NU rdD$_S a.((D$ rD$T_Q4 rD$T_Q2
## redData$g_y 0.677
## rdDt$fd_gr2 -0.044 -0.100
## rdDt$f_NULL 0.105 0.116 0.370
## rdDt$gntc_S 0.090 0.089 -0.029 0.243
## as.n((D$_)) 0.156 -0.037 0.047 -0.033 0.070
## rdDt$mxT_Q4 0.145 -0.008 -0.001 0.058 0.006 0.046
## rdDt$mxT_Q2 -0.476 -0.149 -0.005 -0.079 -0.045 -0.146 -0.494
## rdDt$smpl_y -1.000 -0.678 0.044 -0.105 -0.090 -0.157 -0.148 0.474
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
anova(yMaxSW_year)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value
## redData$age_y 0.50579 0.50579 1 1010 17.1441
## redData$feed_group 0.03623 0.01812 2 1010 0.6141
## redData$genetic_group 0.03860 0.03860 1 1010 1.3085
## as.numeric(paste(redData$sample_interval)) 0.00057 0.00057 1 1010 0.0193
## redData$maxT_Q4 0.05024 0.05024 1 1010 1.7029
## redData$maxT_Q2 0.07097 0.07097 1 1010 2.4056
## redData$sample_year 0.02907 0.02907 1 1010 0.9853
## Pr(>F)
## redData$age_y 3.754e-05 ***
## redData$feed_group 0.5413
## redData$genetic_group 0.2529
## as.numeric(paste(redData$sample_interval)) 0.8895
## redData$maxT_Q4 0.1922
## redData$maxT_Q2 0.1212
## redData$sample_year 0.3211
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AIC(yMaxSW_year)
## [1] -603.0024
min temperature
#minT spring
min_t_sp <- lmer(as.numeric(paste(redData$diff_rltl_res)) ~
redData$age_y +
redData$feed_group +
redData$genetic_group +
as.numeric(paste(redData$sample_interval)) +
redData$minT_Q1 +
(1|redData$recoded_id),
na.action=na.exclude)
## boundary (singular) fit: see ?isSingular
summary(min_t_sp)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## as.numeric(paste(redData$diff_rltl_res)) ~ redData$age_y + redData$feed_group +
## redData$genetic_group + as.numeric(paste(redData$sample_interval)) +
## redData$minT_Q1 + (1 | redData$recoded_id)
##
## REML criterion at convergence: -628.6
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.7556 -0.6973 0.0071 0.6713 3.2318
##
## Random effects:
## Groups Name Variance Std.Dev.
## redData$recoded_id (Intercept) 0.00000 0.0000
## Residual 0.02983 0.1727
## Number of obs: 1019, groups: redData$recoded_id, 305
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) -9.711e-02 2.537e-02 1.012e+03
## redData$age_y 3.119e-02 4.808e-03 1.012e+03
## redData$feed_group2 -1.216e-02 1.212e-02 1.012e+03
## redData$feed_groupNULL -1.312e-02 1.546e-02 1.012e+03
## redData$genetic_groupS -1.239e-02 1.137e-02 1.012e+03
## as.numeric(paste(redData$sample_interval)) 3.023e-06 5.156e-05 1.012e+03
## redData$minT_Q1 2.580e-04 3.921e-03 1.012e+03
## t value Pr(>|t|)
## (Intercept) -3.828 0.000137 ***
## redData$age_y 6.489 1.35e-10 ***
## redData$feed_group2 -1.003 0.316142
## redData$feed_groupNULL -0.849 0.396340
## redData$genetic_groupS -1.090 0.276068
## as.numeric(paste(redData$sample_interval)) 0.059 0.953264
## redData$minT_Q1 0.066 0.947540
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) rdDt$_ rdD$_2 rD$_NU rdD$_S a.((D$
## redData$g_y -0.430
## rdDt$fd_gr2 -0.224 -0.094
## rdDt$f_NULL -0.235 0.074 0.376
## rdDt$gntc_S -0.296 0.054 -0.026 0.237
## as.n((D$_)) -0.726 -0.142 0.051 -0.052 0.058
## rdDt$mnT_Q1 0.412 -0.458 0.027 -0.021 -0.041 -0.044
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
anova(min_t_sp)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value
## redData$age_y 1.25573 1.25573 1 1012 42.1015
## redData$feed_group 0.03772 0.01886 2 1012 0.6324
## redData$genetic_group 0.03542 0.03542 1 1012 1.1876
## as.numeric(paste(redData$sample_interval)) 0.00010 0.00010 1 1012 0.0034
## redData$minT_Q1 0.00013 0.00013 1 1012 0.0043
## Pr(>F)
## redData$age_y 1.354e-10 ***
## redData$feed_group 0.5315
## redData$genetic_group 0.2761
## as.numeric(paste(redData$sample_interval)) 0.9533
## redData$minT_Q1 0.9475
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AIC(min_t_sp)
## [1] -610.5732
#summer
min_t_su <- lmer(as.numeric(paste(redData$diff_rltl_res)) ~
redData$age_y +
redData$feed_group +
redData$genetic_group +
as.numeric(paste(redData$sample_interval)) +
redData$minT_Q2 +
(1|redData$recoded_id),
na.action=na.exclude)
## boundary (singular) fit: see ?isSingular
summary(min_t_su)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## as.numeric(paste(redData$diff_rltl_res)) ~ redData$age_y + redData$feed_group +
## redData$genetic_group + as.numeric(paste(redData$sample_interval)) +
## redData$minT_Q2 + (1 | redData$recoded_id)
##
## REML criterion at convergence: -629
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.7518 -0.7006 0.0088 0.6727 3.2342
##
## Random effects:
## Groups Name Variance Std.Dev.
## redData$recoded_id (Intercept) 0.00000 0.0000
## Residual 0.02982 0.1727
## Number of obs: 1019, groups: redData$recoded_id, 305
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) -9.127e-02 2.879e-02 1.012e+03
## redData$age_y 3.065e-02 4.645e-03 1.012e+03
## redData$feed_group2 -1.212e-02 1.212e-02 1.012e+03
## redData$feed_groupNULL -1.365e-02 1.552e-02 1.012e+03
## redData$genetic_groupS -1.259e-02 1.137e-02 1.012e+03
## as.numeric(paste(redData$sample_interval)) 4.756e-07 5.200e-05 1.012e+03
## redData$minT_Q2 -1.719e-03 4.524e-03 1.012e+03
## t value Pr(>|t|)
## (Intercept) -3.170 0.00157 **
## redData$age_y 6.598 6.71e-11 ***
## redData$feed_group2 -1.000 0.31756
## redData$feed_groupNULL -0.880 0.37929
## redData$genetic_groupS -1.107 0.26860
## as.numeric(paste(redData$sample_interval)) 0.009 0.99270
## redData$minT_Q2 -0.380 0.70406
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) rdDt$_ rdD$_2 rD$_NU rdD$_S a.((D$
## redData$g_y -0.453
## rdDt$fd_gr2 -0.199 -0.090
## rdDt$f_NULL -0.255 0.104 0.374
## rdDt$gntc_S -0.278 0.058 -0.026 0.240
## as.n((D$_)) -0.700 -0.113 0.050 -0.039 0.063
## rdDt$mnT_Q2 -0.596 0.392 -0.013 0.095 0.054 0.137
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
anova(min_t_su)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value
## redData$age_y 1.29828 1.29828 1 1012 43.5342
## redData$feed_group 0.03869 0.01935 2 1012 0.6487
## redData$genetic_group 0.03654 0.03654 1 1012 1.2252
## as.numeric(paste(redData$sample_interval)) 0.00000 0.00000 1 1012 0.0001
## redData$minT_Q2 0.00431 0.00431 1 1012 0.1444
## Pr(>F)
## redData$age_y 6.706e-11 ***
## redData$feed_group 0.5229
## redData$genetic_group 0.2686
## as.numeric(paste(redData$sample_interval)) 0.9927
## redData$minT_Q2 0.7041
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AIC(min_t_su)
## [1] -610.9996
#autumn
min_t_au <- lmer(as.numeric(paste(redData$diff_rltl_res)) ~
redData$age_y +
redData$feed_group +
redData$genetic_group +
as.numeric(paste(redData$sample_interval)) +
redData$minT_Q3 +
(1|redData$recoded_id),
na.action=na.exclude)
## boundary (singular) fit: see ?isSingular
summary(min_t_au)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## as.numeric(paste(redData$diff_rltl_res)) ~ redData$age_y + redData$feed_group +
## redData$genetic_group + as.numeric(paste(redData$sample_interval)) +
## redData$minT_Q3 + (1 | redData$recoded_id)
##
## REML criterion at convergence: -644.5
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.6175 -0.6816 0.0195 0.6763 3.4099
##
## Random effects:
## Groups Name Variance Std.Dev.
## redData$recoded_id (Intercept) 0.00000 0.0000
## Residual 0.02943 0.1716
## Number of obs: 1019, groups: redData$recoded_id, 305
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) 2.713e-01 1.028e-01 1.012e+03
## redData$age_y 2.734e-02 4.383e-03 1.012e+03
## redData$feed_group2 -1.082e-02 1.204e-02 1.012e+03
## redData$feed_groupNULL -1.423e-02 1.535e-02 1.012e+03
## redData$genetic_groupS -1.234e-02 1.128e-02 1.012e+03
## as.numeric(paste(redData$sample_interval)) 1.170e-05 5.122e-05 1.012e+03
## redData$minT_Q3 -4.891e-02 1.328e-02 1.012e+03
## t value Pr(>|t|)
## (Intercept) 2.639 0.008444 **
## redData$age_y 6.238 6.49e-10 ***
## redData$feed_group2 -0.899 0.369103
## redData$feed_groupNULL -0.927 0.354335
## redData$genetic_groupS -1.094 0.274236
## as.numeric(paste(redData$sample_interval)) 0.228 0.819391
## redData$minT_Q3 -3.683 0.000243 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) rdDt$_ rdD$_2 rD$_NU rdD$_S a.((D$
## redData$g_y -0.306
## rdDt$fd_gr2 -0.028 -0.096
## rdDt$f_NULL -0.075 0.075 0.376
## rdDt$gntc_S -0.068 0.039 -0.025 0.237
## as.n((D$_)) -0.129 -0.188 0.053 -0.054 0.057
## rdDt$mnT_Q3 -0.975 0.248 -0.031 0.020 0.000 -0.045
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
anova(min_t_au)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value
## redData$age_y 1.14541 1.14541 1 1012 38.9172
## redData$feed_group 0.03565 0.01783 2 1012 0.6057
## redData$genetic_group 0.03522 0.03522 1 1012 1.1967
## as.numeric(paste(redData$sample_interval)) 0.00154 0.00154 1 1012 0.0522
## redData$minT_Q3 0.39924 0.39924 1 1012 13.5650
## Pr(>F)
## redData$age_y 6.488e-10 ***
## redData$feed_group 0.5459076
## redData$genetic_group 0.2742360
## as.numeric(paste(redData$sample_interval)) 0.8193906
## redData$minT_Q3 0.0002426 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AIC(min_t_au)
## [1] -626.497
tableS16 <- as.data.frame(round(coef(summary(min_t_au)),3))
tableS16
## Estimate Std. Error df t value
## (Intercept) 0.271 0.103 1012 2.639
## redData$age_y 0.027 0.004 1012 6.238
## redData$feed_group2 -0.011 0.012 1012 -0.899
## redData$feed_groupNULL -0.014 0.015 1012 -0.927
## redData$genetic_groupS -0.012 0.011 1012 -1.094
## as.numeric(paste(redData$sample_interval)) 0.000 0.000 1012 0.228
## redData$minT_Q3 -0.049 0.013 1012 -3.683
## Pr(>|t|)
## (Intercept) 0.008
## redData$age_y 0.000
## redData$feed_group2 0.369
## redData$feed_groupNULL 0.354
## redData$genetic_groupS 0.274
## as.numeric(paste(redData$sample_interval)) 0.819
## redData$minT_Q3 0.000
tableS17 <- as.data.frame(anova(min_t_au))
tableS17
## Sum Sq Mean Sq NumDF DenDF
## redData$age_y 1.145406321 1.145406321 1 1012
## redData$feed_group 0.035651868 0.017825934 2 1012
## redData$genetic_group 0.035222084 0.035222084 1 1012
## as.numeric(paste(redData$sample_interval)) 0.001535201 0.001535201 1 1012
## redData$minT_Q3 0.399243825 0.399243825 1 1012
## F value Pr(>F)
## redData$age_y 38.91720933 6.488298e-10
## redData$feed_group 0.60566770 5.459076e-01
## redData$genetic_group 1.19673271 2.742360e-01
## as.numeric(paste(redData$sample_interval)) 0.05216118 8.193906e-01
## redData$minT_Q3 13.56501639 2.426334e-04
# min autumn & max summer
min_t_au_max_su <- lmer(as.numeric(paste(redData$diff_rltl_res)) ~
redData$age_y +
redData$feed_group +
redData$genetic_group +
as.numeric(paste(redData$sample_interval)) +
redData$minT_Q3 +
redData$maxT_Q2 +
(1|redData$recoded_id),
na.action=na.exclude)
## boundary (singular) fit: see ?isSingular
summary(min_t_au_max_su)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## as.numeric(paste(redData$diff_rltl_res)) ~ redData$age_y + redData$feed_group +
## redData$genetic_group + as.numeric(paste(redData$sample_interval)) +
## redData$minT_Q3 + redData$maxT_Q2 + (1 | redData$recoded_id)
##
## REML criterion at convergence: -636.7
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.6145 -0.6817 0.0212 0.6765 3.4092
##
## Random effects:
## Groups Name Variance Std.Dev.
## redData$recoded_id (Intercept) 0.00000 0.0000
## Residual 0.02946 0.1716
## Number of obs: 1019, groups: redData$recoded_id, 305
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) 2.743e-01 1.255e-01 1.011e+03
## redData$age_y 2.734e-02 4.385e-03 1.011e+03
## redData$feed_group2 -1.082e-02 1.205e-02 1.011e+03
## redData$feed_groupNULL -1.427e-02 1.540e-02 1.011e+03
## redData$genetic_groupS -1.235e-02 1.129e-02 1.011e+03
## as.numeric(paste(redData$sample_interval)) 1.151e-05 5.146e-05 1.011e+03
## redData$minT_Q3 -5.001e-02 2.998e-02 1.011e+03
## redData$maxT_Q2 3.270e-04 7.946e-03 1.011e+03
## t value Pr(>|t|)
## (Intercept) 2.186 0.0290 *
## redData$age_y 6.235 6.61e-10 ***
## redData$feed_group2 -0.898 0.3692
## redData$feed_groupNULL -0.927 0.3543
## redData$genetic_groupS -1.094 0.2742
## as.numeric(paste(redData$sample_interval)) 0.224 0.8231
## redData$minT_Q3 -1.668 0.0955 .
## redData$maxT_Q2 0.041 0.9672
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) rdDt$_ rdD$_2 rD$_NU rdD$_S a.((D$ rD$T_Q3
## redData$g_y -0.249
## rdDt$fd_gr2 -0.026 -0.096
## rdDt$f_NULL -0.102 0.075 0.375
## rdDt$gntc_S -0.066 0.039 -0.025 0.237
## as.n((D$_)) -0.158 -0.188 0.053 -0.047 0.058
## rdDt$mnT_Q3 -0.867 0.107 -0.008 0.073 0.015 0.061
## rdDt$mxT_Q2 0.573 0.004 -0.006 -0.072 -0.017 -0.090 -0.896
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
anova(min_t_au_max_su)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value
## redData$age_y 1.14545 1.14545 1 1011 38.8802
## redData$feed_group 0.03570 0.01785 2 1011 0.6058
## redData$genetic_group 0.03526 0.03526 1 1011 1.1967
## as.numeric(paste(redData$sample_interval)) 0.00147 0.00147 1 1011 0.0500
## redData$minT_Q3 0.08201 0.08201 1 1011 2.7837
## redData$maxT_Q2 0.00005 0.00005 1 1011 0.0017
## Pr(>F)
## redData$age_y 6.61e-10 ***
## redData$feed_group 0.54581
## redData$genetic_group 0.27423
## as.numeric(paste(redData$sample_interval)) 0.82310
## redData$minT_Q3 0.09554 .
## redData$maxT_Q2 0.96718
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AIC(min_t_au_max_su)
## [1] -616.6658
tableS18<-as.data.frame(round(coef(summary(min_t_au_max_su)),3))
tableS18
## Estimate Std. Error df t value
## (Intercept) 0.274 0.125 1011 2.186
## redData$age_y 0.027 0.004 1011 6.235
## redData$feed_group2 -0.011 0.012 1011 -0.898
## redData$feed_groupNULL -0.014 0.015 1011 -0.927
## redData$genetic_groupS -0.012 0.011 1011 -1.094
## as.numeric(paste(redData$sample_interval)) 0.000 0.000 1011 0.224
## redData$minT_Q3 -0.050 0.030 1011 -1.668
## redData$maxT_Q2 0.000 0.008 1011 0.041
## Pr(>|t|)
## (Intercept) 0.029
## redData$age_y 0.000
## redData$feed_group2 0.369
## redData$feed_groupNULL 0.354
## redData$genetic_groupS 0.274
## as.numeric(paste(redData$sample_interval)) 0.823
## redData$minT_Q3 0.096
## redData$maxT_Q2 0.967
tableS19<-as.data.frame(anova(min_t_au_max_su))
tableS19
## Sum Sq Mean Sq NumDF
## redData$age_y 1.145446e+00 1.145446e+00 1
## redData$feed_group 3.569759e-02 1.784879e-02 2
## redData$genetic_group 3.525711e-02 3.525711e-02 1
## as.numeric(paste(redData$sample_interval)) 1.473167e-03 1.473167e-03 1
## redData$minT_Q3 8.200949e-02 8.200949e-02 1
## redData$maxT_Q2 4.989816e-05 4.989816e-05 1
## DenDF F value Pr(>F)
## redData$age_y 1011 38.880150364 6.610440e-10
## redData$feed_group 1011 0.605846118 5.458105e-01
## redData$genetic_group 1011 1.196741170 2.742346e-01
## as.numeric(paste(redData$sample_interval)) 1011 0.050004094 8.231013e-01
## redData$minT_Q3 1011 2.783668934 9.553942e-02
## redData$maxT_Q2 1011 0.001693706 9.671807e-01
#winter
min_t_wi <- lmer(as.numeric(paste(redData$diff_rltl_res)) ~
redData$age_y +
redData$feed_group +
redData$genetic_group +
as.numeric(paste(redData$sample_interval)) +
redData$minT_Q4 +
(1 | redData$recoded_id),
na.action = na.exclude)
## boundary (singular) fit: see ?isSingular
summary(min_t_wi)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## as.numeric(paste(redData$diff_rltl_res)) ~ redData$age_y + redData$feed_group +
## redData$genetic_group + as.numeric(paste(redData$sample_interval)) +
## redData$minT_Q4 + (1 | redData$recoded_id)
##
## REML criterion at convergence: -630.6
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.7642 -0.6855 0.0232 0.6679 3.2393
##
## Random effects:
## Groups Name Variance Std.Dev.
## redData$recoded_id (Intercept) 0.00000 0.0000
## Residual 0.02973 0.1724
## Number of obs: 1019, groups: redData$recoded_id, 305
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) -8.598e-02 2.403e-02 1.012e+03
## redData$age_y 2.825e-02 4.614e-03 1.012e+03
## redData$feed_group2 -1.151e-02 1.210e-02 1.012e+03
## redData$feed_groupNULL -1.244e-02 1.543e-02 1.012e+03
## redData$genetic_groupS -1.262e-02 1.134e-02 1.012e+03
## as.numeric(paste(redData$sample_interval)) 7.699e-06 5.150e-05 1.012e+03
## redData$minT_Q4 4.048e-03 2.294e-03 1.012e+03
## t value Pr(>|t|)
## (Intercept) -3.578 0.000362 ***
## redData$age_y 6.122 1.32e-09 ***
## redData$feed_group2 -0.951 0.341780
## redData$feed_groupNULL -0.806 0.420532
## redData$genetic_groupS -1.113 0.265938
## as.numeric(paste(redData$sample_interval)) 0.150 0.881183
## redData$minT_Q4 1.765 0.077879 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) rdDt$_ rdD$_2 rD$_NU rdD$_S a.((D$
## redData$g_y -0.370
## rdDt$fd_gr2 -0.239 -0.097
## rdDt$f_NULL -0.232 0.058 0.377
## rdDt$gntc_S -0.298 0.042 -0.026 0.236
## as.n((D$_)) -0.732 -0.188 0.053 -0.052 0.056
## rdDt$mnT_Q4 0.279 -0.380 0.031 0.024 -0.013 0.050
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
anova(min_t_wi)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value
## redData$age_y 1.11450 1.11450 1 1012 37.4812
## redData$feed_group 0.03383 0.01691 2 1012 0.5688
## redData$genetic_group 0.03684 0.03684 1 1012 1.2389
## as.numeric(paste(redData$sample_interval)) 0.00066 0.00066 1 1012 0.0224
## redData$minT_Q4 0.09262 0.09262 1 1012 3.1149
## Pr(>F)
## redData$age_y 1.319e-09 ***
## redData$feed_group 0.56636
## redData$genetic_group 0.26594
## as.numeric(paste(redData$sample_interval)) 0.88118
## redData$minT_Q4 0.07788 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AIC(min_t_wi)
## [1] -612.61
mean rain
# spring
r_sp <- lmer(as.numeric(paste(redData$diff_rltl_res)) ~
redData$age_y +
redData$feed_group +
redData$genetic_group +
as.numeric(paste(redData$sample_interval)) +
redData$mean_rain_Q1 +
(1 | redData$recoded_id),
na.action = na.exclude)
## boundary (singular) fit: see ?isSingular
summary(r_sp)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## as.numeric(paste(redData$diff_rltl_res)) ~ redData$age_y + redData$feed_group +
## redData$genetic_group + as.numeric(paste(redData$sample_interval)) +
## redData$mean_rain_Q1 + (1 | redData$recoded_id)
##
## REML criterion at convergence: -623.5
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.8068 -0.7032 0.0095 0.6709 3.1926
##
## Random effects:
## Groups Name Variance Std.Dev.
## redData$recoded_id (Intercept) 0.00000 0.0000
## Residual 0.02976 0.1725
## Number of obs: 1019, groups: redData$recoded_id, 305
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) -8.613e-02 2.440e-02 1.012e+03
## redData$age_y 3.413e-02 4.669e-03 1.012e+03
## redData$feed_group2 -1.233e-02 1.210e-02 1.012e+03
## redData$feed_groupNULL -1.129e-02 1.549e-02 1.012e+03
## redData$genetic_groupS -1.133e-02 1.137e-02 1.012e+03
## as.numeric(paste(redData$sample_interval)) 1.486e-05 5.206e-05 1.012e+03
## redData$mean_rain_Q1 -1.511e-04 1.024e-04 1.012e+03
## t value Pr(>|t|)
## (Intercept) -3.529 0.000435 ***
## redData$age_y 7.309 5.45e-13 ***
## redData$feed_group2 -1.019 0.308643
## redData$feed_groupNULL -0.729 0.466209
## redData$genetic_groupS -0.997 0.319101
## as.numeric(paste(redData$sample_interval)) 0.285 0.775413
## redData$mean_rain_Q1 -1.475 0.140445
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) rdDt$_ rdD$_2 rD$_NU rdD$_S a.((D$
## redData$g_y -0.126
## rdDt$fd_gr2 -0.247 -0.087
## rdDt$f_NULL -0.209 0.098 0.375
## rdDt$gntc_S -0.270 0.061 -0.026 0.240
## as.n((D$_)) -0.678 -0.104 0.050 -0.040 0.065
## rdDt$mn__Q1 -0.324 -0.405 0.008 -0.079 -0.061 -0.152
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
anova(r_sp)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value
## redData$age_y 1.59006 1.59006 1 1012 53.4251
## redData$feed_group 0.03505 0.01753 2 1012 0.5889
## redData$genetic_group 0.02957 0.02957 1 1012 0.9936
## as.numeric(paste(redData$sample_interval)) 0.00242 0.00242 1 1012 0.0814
## redData$mean_rain_Q1 0.06478 0.06478 1 1012 2.1765
## Pr(>F)
## redData$age_y 5.446e-13 ***
## redData$feed_group 0.5551
## redData$genetic_group 0.3191
## as.numeric(paste(redData$sample_interval)) 0.7754
## redData$mean_rain_Q1 0.1404
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AIC(r_sp)
## [1] -605.456
# summer
r_su <- lmer(as.numeric(paste(redData$diff_rltl_res)) ~
redData$age_y +
redData$feed_group +
redData$genetic_group +
as.numeric(paste(redData$sample_interval)) +
redData$mean_rain_Q2 +
(1 | redData$recoded_id),
na.action = na.exclude)
## boundary (singular) fit: see ?isSingular
summary(r_su)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## as.numeric(paste(redData$diff_rltl_res)) ~ redData$age_y + redData$feed_group +
## redData$genetic_group + as.numeric(paste(redData$sample_interval)) +
## redData$mean_rain_Q2 + (1 | redData$recoded_id)
##
## REML criterion at convergence: -626.4
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.7692 -0.6823 0.0235 0.6660 3.2388
##
## Random effects:
## Groups Name Variance Std.Dev.
## redData$recoded_id (Intercept) 0.0000 0.0000
## Residual 0.0297 0.1723
## Number of obs: 1019, groups: redData$recoded_id, 305
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) -1.342e-01 2.909e-02 1.012e+03
## redData$age_y 2.871e-02 4.454e-03 1.012e+03
## redData$feed_group2 -1.149e-02 1.210e-02 1.012e+03
## redData$feed_groupNULL -1.208e-02 1.543e-02 1.012e+03
## redData$genetic_groupS -1.239e-02 1.133e-02 1.012e+03
## as.numeric(paste(redData$sample_interval)) 1.071e-05 5.154e-05 1.012e+03
## redData$mean_rain_Q2 3.329e-04 1.623e-04 1.012e+03
## t value Pr(>|t|)
## (Intercept) -4.612 4.50e-06 ***
## redData$age_y 6.446 1.77e-10 ***
## redData$feed_group2 -0.950 0.3425
## redData$feed_groupNULL -0.783 0.4338
## redData$genetic_groupS -1.093 0.2746
## as.numeric(paste(redData$sample_interval)) 0.208 0.8354
## redData$mean_rain_Q2 2.051 0.0405 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) rdDt$_ rdD$_2 rD$_NU rdD$_S a.((D$
## redData$g_y -0.050
## rdDt$fd_gr2 -0.222 -0.096
## rdDt$f_NULL -0.217 0.060 0.377
## rdDt$gntc_S -0.242 0.039 -0.025 0.236
## as.n((D$_)) -0.659 -0.195 0.054 -0.051 0.057
## rdDt$mn__Q2 -0.610 -0.288 0.028 0.032 -0.001 0.071
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
anova(r_su)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value
## redData$age_y 1.23429 1.23429 1 1012 41.5544
## redData$feed_group 0.03304 0.01652 2 1012 0.5562
## redData$genetic_group 0.03549 0.03549 1 1012 1.1948
## as.numeric(paste(redData$sample_interval)) 0.00128 0.00128 1 1012 0.0432
## redData$mean_rain_Q2 0.12497 0.12497 1 1012 4.2074
## Pr(>F)
## redData$age_y 1.771e-10 ***
## redData$feed_group 0.57357
## redData$genetic_group 0.27462
## as.numeric(paste(redData$sample_interval)) 0.83537
## redData$mean_rain_Q2 0.04051 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AIC(r_su)
## [1] -608.4028
tableS20 <- as.data.frame(round(coef(summary(r_su)), 3))
tableS20
## Estimate Std. Error df t value
## (Intercept) -0.134 0.029 1012 -4.612
## redData$age_y 0.029 0.004 1012 6.446
## redData$feed_group2 -0.011 0.012 1012 -0.950
## redData$feed_groupNULL -0.012 0.015 1012 -0.783
## redData$genetic_groupS -0.012 0.011 1012 -1.093
## as.numeric(paste(redData$sample_interval)) 0.000 0.000 1012 0.208
## redData$mean_rain_Q2 0.000 0.000 1012 2.051
## Pr(>|t|)
## (Intercept) 0.000
## redData$age_y 0.000
## redData$feed_group2 0.342
## redData$feed_groupNULL 0.434
## redData$genetic_groupS 0.275
## as.numeric(paste(redData$sample_interval)) 0.835
## redData$mean_rain_Q2 0.041
tableS21 <- as.data.frame(anova(r_su))
tableS21
## Sum Sq Mean Sq NumDF DenDF
## redData$age_y 1.234287347 1.234287347 1 1012
## redData$feed_group 0.033040615 0.016520307 2 1012
## redData$genetic_group 0.035489953 0.035489953 1 1012
## as.numeric(paste(redData$sample_interval)) 0.001283502 0.001283502 1 1012
## redData$mean_rain_Q2 0.124970882 0.124970882 1 1012
## F value Pr(>F)
## redData$age_y 41.55444935 1.771323e-10
## redData$feed_group 0.55618514 5.735675e-01
## redData$genetic_group 1.19483156 2.746173e-01
## as.numeric(paste(redData$sample_interval)) 0.04321134 8.353697e-01
## redData$mean_rain_Q2 4.20736404 4.050585e-02
# autumn
r_au <- lmer(as.numeric(paste(redData$diff_rltl_res)) ~
redData$age_y +
redData$feed_group +
redData$genetic_group +
as.numeric(paste(redData$sample_interval)) +
redData$mean_rain_Q3 +
(1 | redData$recoded_id), na.action = na.exclude)
## boundary (singular) fit: see ?isSingular
summary(r_au)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## as.numeric(paste(redData$diff_rltl_res)) ~ redData$age_y + redData$feed_group +
## redData$genetic_group + as.numeric(paste(redData$sample_interval)) +
## redData$mean_rain_Q3 + (1 | redData$recoded_id)
##
## REML criterion at convergence: -622.5
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.7671 -0.7007 0.0110 0.6702 3.2207
##
## Random effects:
## Groups Name Variance Std.Dev.
## redData$recoded_id (Intercept) 0.00000 0.0000
## Residual 0.02983 0.1727
## Number of obs: 1019, groups: redData$recoded_id, 305
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) -1.036e-01 4.676e-02 1.012e+03
## redData$age_y 3.171e-02 5.006e-03 1.012e+03
## redData$feed_group2 -1.222e-02 1.212e-02 1.012e+03
## redData$feed_groupNULL -1.294e-02 1.549e-02 1.012e+03
## redData$genetic_groupS -1.226e-02 1.138e-02 1.012e+03
## as.numeric(paste(redData$sample_interval)) 4.038e-06 5.187e-05 1.012e+03
## redData$mean_rain_Q3 2.664e-05 1.865e-04 1.012e+03
## t value Pr(>|t|)
## (Intercept) -2.215 0.027 *
## redData$age_y 6.334 3.58e-10 ***
## redData$feed_group2 -1.008 0.313
## redData$feed_groupNULL -0.835 0.404
## redData$genetic_groupS -1.077 0.282
## as.numeric(paste(redData$sample_interval)) 0.078 0.938
## redData$mean_rain_Q3 0.143 0.886
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) rdDt$_ rdD$_2 rD$_NU rdD$_S a.((D$
## redData$g_y -0.578
## rdDt$fd_gr2 -0.105 -0.092
## rdDt$f_NULL -0.184 0.099 0.374
## rdDt$gntc_S -0.205 0.066 -0.027 0.240
## as.n((D$_)) -0.483 -0.094 0.048 -0.044 0.063
## rdDt$mn__Q3 -0.869 0.521 -0.026 0.071 0.062 0.117
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
anova(r_au)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value
## redData$age_y 1.19669 1.19669 1 1012 40.1227
## redData$feed_group 0.03761 0.01881 2 1012 0.6305
## redData$genetic_group 0.03460 0.03460 1 1012 1.1602
## as.numeric(paste(redData$sample_interval)) 0.00018 0.00018 1 1012 0.0061
## redData$mean_rain_Q3 0.00061 0.00061 1 1012 0.0204
## Pr(>F)
## redData$age_y 3.582e-10 ***
## redData$feed_group 0.5325
## redData$genetic_group 0.2817
## as.numeric(paste(redData$sample_interval)) 0.9380
## redData$mean_rain_Q3 0.8865
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AIC(r_au)
## [1] -604.4984
# winter
r_wi <- lmer(as.numeric(paste(redData$diff_rltl_res)) ~
redData$age_y +
redData$feed_group +
redData$genetic_group +
as.numeric(paste(redData$sample_interval)) +
redData$mean_rain_Q4 +
(1 | redData$recoded_id),
na.action = na.exclude)
## boundary (singular) fit: see ?isSingular
summary(r_wi)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## as.numeric(paste(redData$diff_rltl_res)) ~ redData$age_y + redData$feed_group +
## redData$genetic_group + as.numeric(paste(redData$sample_interval)) +
## redData$mean_rain_Q4 + (1 | redData$recoded_id)
##
## REML criterion at convergence: -622.2
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.7762 -0.7014 0.0090 0.6741 3.2152
##
## Random effects:
## Groups Name Variance Std.Dev.
## redData$recoded_id (Intercept) 0.00000 0.0000
## Residual 0.02981 0.1727
## Number of obs: 1019, groups: redData$recoded_id, 305
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) -1.142e-01 3.463e-02 1.012e+03
## redData$age_y 3.033e-02 4.562e-03 1.012e+03
## redData$feed_group2 -1.200e-02 1.212e-02 1.012e+03
## redData$feed_groupNULL -1.278e-02 1.546e-02 1.012e+03
## redData$genetic_groupS -1.248e-02 1.136e-02 1.012e+03
## as.numeric(paste(redData$sample_interval)) 4.304e-06 5.153e-05 1.012e+03
## redData$mean_rain_Q4 8.479e-05 1.336e-04 1.012e+03
## t value Pr(>|t|)
## (Intercept) -3.296 0.00101 **
## redData$age_y 6.648 4.86e-11 ***
## redData$feed_group2 -0.990 0.32223
## redData$feed_groupNULL -0.826 0.40874
## redData$genetic_groupS -1.099 0.27219
## as.numeric(paste(redData$sample_interval)) 0.084 0.93345
## redData$mean_rain_Q4 0.635 0.52580
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) rdDt$_ rdD$_2 rD$_NU rdD$_S a.((D$
## redData$g_y 0.075
## rdDt$fd_gr2 -0.189 -0.094
## rdDt$f_NULL -0.190 0.057 0.377
## rdDt$gntc_S -0.192 0.043 -0.026 0.236
## as.n((D$_)) -0.545 -0.183 0.053 -0.052 0.056
## rdDt$mn__Q4 -0.745 -0.350 0.023 0.032 -0.017 0.035
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
anova(r_wi)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value
## redData$age_y 1.31752 1.31752 1 1012 44.1906
## redData$feed_group 0.03637 0.01819 2 1012 0.6100
## redData$genetic_group 0.03599 0.03599 1 1012 1.2070
## as.numeric(paste(redData$sample_interval)) 0.00021 0.00021 1 1012 0.0070
## redData$mean_rain_Q4 0.01201 0.01201 1 1012 0.4028
## Pr(>F)
## redData$age_y 4.863e-11 ***
## redData$feed_group 0.5435
## redData$genetic_group 0.2722
## as.numeric(paste(redData$sample_interval)) 0.9334
## redData$mean_rain_Q4 0.5258
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AIC(r_wi)
## [1] -604.2137
Mean sun hours
# spring
sh_sp <- lmer(as.numeric(paste(redData$diff_rltl_res)) ~
redData$age_y +
redData$feed_group +
redData$genetic_group +
as.numeric(paste(redData$sample_interval)) +
redData$mean_sun_hours_Q1 +
(1 | redData$recoded_id),
na.action = na.exclude)
## boundary (singular) fit: see ?isSingular
summary(sh_sp)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## as.numeric(paste(redData$diff_rltl_res)) ~ redData$age_y + redData$feed_group +
## redData$genetic_group + as.numeric(paste(redData$sample_interval)) +
## redData$mean_sun_hours_Q1 + (1 | redData$recoded_id)
##
## REML criterion at convergence: -625.8
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.7673 -0.7073 0.0156 0.6649 3.2293
##
## Random effects:
## Groups Name Variance Std.Dev.
## redData$recoded_id (Intercept) 0.00000 0.0000
## Residual 0.02978 0.1726
## Number of obs: 1019, groups: redData$recoded_id, 305
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) -1.418e-01 4.371e-02 1.012e+03
## redData$age_y 3.412e-02 4.872e-03 1.012e+03
## redData$feed_group2 -1.234e-02 1.211e-02 1.012e+03
## redData$feed_groupNULL -1.136e-02 1.551e-02 1.012e+03
## redData$genetic_groupS -1.137e-02 1.138e-02 1.012e+03
## as.numeric(paste(redData$sample_interval)) 1.406e-05 5.229e-05 1.012e+03
## redData$mean_sun_hours_Q1 5.850e-04 4.929e-04 1.012e+03
## t value Pr(>|t|)
## (Intercept) -3.245 0.00121 **
## redData$age_y 7.003 4.56e-12 ***
## redData$feed_group2 -1.019 0.30841
## redData$feed_groupNULL -0.732 0.46422
## redData$genetic_groupS -0.999 0.31780
## as.numeric(paste(redData$sample_interval)) 0.269 0.78810
## redData$mean_sun_hours_Q1 1.187 0.23555
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) rdDt$_ rdD$_2 rD$_NU rdD$_S a.((D$
## redData$g_y -0.546
## rdDt$fd_gr2 -0.127 -0.086
## rdDt$f_NULL -0.211 0.109 0.374
## rdDt$gntc_S -0.223 0.070 -0.026 0.242
## as.n((D$_)) -0.554 -0.073 0.049 -0.036 0.069
## rdDt$m___Q1 -0.849 0.481 -0.011 0.094 0.073 0.175
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
anova(sh_sp)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value
## redData$age_y 1.46073 1.46073 1 1012 49.0424
## redData$feed_group 0.03520 0.01760 2 1012 0.5909
## redData$genetic_group 0.02975 0.02975 1 1012 0.9990
## as.numeric(paste(redData$sample_interval)) 0.00215 0.00215 1 1012 0.0723
## redData$mean_sun_hours_Q1 0.04196 0.04196 1 1012 1.4087
## Pr(>F)
## redData$age_y 4.56e-12 ***
## redData$feed_group 0.5540
## redData$genetic_group 0.3178
## as.numeric(paste(redData$sample_interval)) 0.7881
## redData$mean_sun_hours_Q1 0.2355
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AIC(sh_sp)
## [1] -607.8305
# summer
sh_su <- lmer(as.numeric(paste(redData$diff_rltl_res)) ~
redData$age_y +
redData$feed_group +
redData$genetic_group +
as.numeric(paste(redData$sample_interval)) +
redData$mean_sun_hours_Q2 +
(1 | redData$recoded_id),
na.action = na.exclude)
## boundary (singular) fit: see ?isSingular
summary(sh_su)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## as.numeric(paste(redData$diff_rltl_res)) ~ redData$age_y + redData$feed_group +
## redData$genetic_group + as.numeric(paste(redData$sample_interval)) +
## redData$mean_sun_hours_Q2 + (1 | redData$recoded_id)
##
## REML criterion at convergence: -629.7
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.7213 -0.6709 0.0219 0.6667 3.2782
##
## Random effects:
## Groups Name Variance Std.Dev.
## redData$recoded_id (Intercept) 0.00000 0.0000
## Residual 0.02967 0.1723
## Number of obs: 1019, groups: redData$recoded_id, 305
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) 5.951e-02 7.193e-02 1.012e+03
## redData$age_y 2.485e-02 5.105e-03 1.012e+03
## redData$feed_group2 -1.115e-02 1.209e-02 1.012e+03
## redData$feed_groupNULL -1.553e-02 1.545e-02 1.012e+03
## redData$genetic_groupS -1.372e-02 1.134e-02 1.012e+03
## as.numeric(paste(redData$sample_interval)) -5.398e-06 5.151e-05 1.012e+03
## redData$mean_sun_hours_Q2 -1.104e-03 4.784e-04 1.012e+03
## t value Pr(>|t|)
## (Intercept) 0.827 0.4082
## redData$age_y 4.868 1.31e-06 ***
## redData$feed_group2 -0.922 0.3568
## redData$feed_groupNULL -1.005 0.3149
## redData$genetic_groupS -1.210 0.2267
## as.numeric(paste(redData$sample_interval)) -0.105 0.9166
## redData$mean_sun_hours_Q2 -2.309 0.0212 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) rdDt$_ rdD$_2 rD$_NU rdD$_S a.((D$
## redData$g_y -0.601
## rdDt$fd_gr2 -0.048 -0.097
## rdDt$f_NULL -0.144 0.098 0.373
## rdDt$gntc_S -0.147 0.062 -0.027 0.239
## as.n((D$_)) -0.317 -0.113 0.049 -0.048 0.060
## rdDt$m___Q2 -0.947 0.550 -0.037 0.068 0.052 0.072
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
anova(sh_su)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value
## redData$age_y 0.70314 0.70314 1 1012 23.6984
## redData$feed_group 0.04030 0.02015 2 1012 0.6792
## redData$genetic_group 0.04341 0.04341 1 1012 1.4629
## as.numeric(paste(redData$sample_interval)) 0.00033 0.00033 1 1012 0.0110
## redData$mean_sun_hours_Q2 0.15816 0.15816 1 1012 5.3307
## Pr(>F)
## redData$age_y 1.306e-06 ***
## redData$feed_group 0.50726
## redData$genetic_group 0.22674
## as.numeric(paste(redData$sample_interval)) 0.91656
## redData$mean_sun_hours_Q2 0.02115 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AIC(sh_su)
## [1] -611.6836
tableS22 <- as.data.frame(round(coef(summary(sh_su)), 3))
tableS22
## Estimate Std. Error df t value
## (Intercept) 0.060 0.072 1012 0.827
## redData$age_y 0.025 0.005 1012 4.868
## redData$feed_group2 -0.011 0.012 1012 -0.922
## redData$feed_groupNULL -0.016 0.015 1012 -1.005
## redData$genetic_groupS -0.014 0.011 1012 -1.210
## as.numeric(paste(redData$sample_interval)) 0.000 0.000 1012 -0.105
## redData$mean_sun_hours_Q2 -0.001 0.000 1012 -2.309
## Pr(>|t|)
## (Intercept) 0.408
## redData$age_y 0.000
## redData$feed_group2 0.357
## redData$feed_groupNULL 0.315
## redData$genetic_groupS 0.227
## as.numeric(paste(redData$sample_interval)) 0.917
## redData$mean_sun_hours_Q2 0.021
tableS23 <- as.data.frame(anova(sh_su))
tableS23
## Sum Sq Mean Sq NumDF
## redData$age_y 0.7031350286 0.7031350286 1
## redData$feed_group 0.0403026834 0.0201513417 2
## redData$genetic_group 0.0434058434 0.0434058434 1
## as.numeric(paste(redData$sample_interval)) 0.0003258131 0.0003258131 1
## redData$mean_sun_hours_Q2 0.1581635496 0.1581635496 1
## DenDF F value Pr(>F)
## redData$age_y 1012 23.6984433 1.306466e-06
## redData$feed_group 1012 0.6791803 5.072634e-01
## redData$genetic_group 1012 1.4629493 2.267439e-01
## as.numeric(paste(redData$sample_interval)) 1012 0.0109812 9.165623e-01
## redData$mean_sun_hours_Q2 1012 5.3307398 2.115323e-02
# autumn
sh_au <- lmer(as.numeric(paste(redData$diff_rltl_res)) ~
redData$age_y +
redData$feed_group +
redData$genetic_group +
as.numeric(paste(redData$sample_interval)) +
redData$mean_sun_hours_Q3 +
(1 | redData$recoded_id),
na.action = na.exclude)
## boundary (singular) fit: see ?isSingular
summary(sh_au)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## as.numeric(paste(redData$diff_rltl_res)) ~ redData$age_y + redData$feed_group +
## redData$genetic_group + as.numeric(paste(redData$sample_interval)) +
## redData$mean_sun_hours_Q3 + (1 | redData$recoded_id)
##
## REML criterion at convergence: -626.2
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.7835 -0.7088 0.0121 0.6749 3.2061
##
## Random effects:
## Groups Name Variance Std.Dev.
## redData$recoded_id (Intercept) 0.0000 0.0000
## Residual 0.0298 0.1726
## Number of obs: 1019, groups: redData$recoded_id, 305
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) -3.283e-02 6.771e-02 1.012e+03
## redData$age_y 3.321e-02 4.649e-03 1.012e+03
## redData$feed_group2 -1.238e-02 1.211e-02 1.012e+03
## redData$feed_groupNULL -1.285e-02 1.545e-02 1.012e+03
## redData$genetic_groupS -1.188e-02 1.136e-02 1.012e+03
## as.numeric(paste(redData$sample_interval)) 6.253e-06 5.158e-05 1.012e+03
## redData$mean_sun_hours_Q3 -7.300e-04 7.151e-04 1.012e+03
## t value Pr(>|t|)
## (Intercept) -0.485 0.628
## redData$age_y 7.144 1.74e-12 ***
## redData$feed_group2 -1.022 0.307
## redData$feed_groupNULL -0.832 0.406
## redData$genetic_groupS -1.046 0.296
## as.numeric(paste(redData$sample_interval)) 0.121 0.904
## redData$mean_sun_hours_Q3 -1.021 0.308
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) rdDt$_ rdD$_2 rD$_NU rdD$_S a.((D$
## redData$g_y 0.278
## rdDt$fd_gr2 -0.104 -0.091
## rdDt$f_NULL -0.071 0.073 0.376
## rdDt$gntc_S -0.066 0.053 -0.026 0.237
## as.n((D$_)) -0.210 -0.145 0.051 -0.052 0.059
## rdDt$m___Q3 -0.940 -0.394 0.017 -0.015 -0.041 -0.059
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
anova(sh_au)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value
## redData$age_y 1.52048 1.52048 1 1012 51.0302
## redData$feed_group 0.03809 0.01905 2 1012 0.6393
## redData$genetic_group 0.03260 0.03260 1 1012 1.0940
## as.numeric(paste(redData$sample_interval)) 0.00044 0.00044 1 1012 0.0147
## redData$mean_sun_hours_Q3 0.03105 0.03105 1 1012 1.0420
## Pr(>F)
## redData$age_y 1.737e-12 ***
## redData$feed_group 0.5279
## redData$genetic_group 0.2958
## as.numeric(paste(redData$sample_interval)) 0.9035
## redData$mean_sun_hours_Q3 0.3076
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AIC(sh_au)
## [1] -608.2083
# winter
sh_wi <- lmer(as.numeric(paste(redData$diff_rltl_res)) ~
redData$age_y +
redData$feed_group +
redData$genetic_group +
as.numeric(paste(redData$sample_interval)) +
redData$mean_sun_hours_Q4 +
(1 | redData$recoded_id), na.action = na.exclude)
## boundary (singular) fit: see ?isSingular
summary(sh_wi)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## as.numeric(paste(redData$diff_rltl_res)) ~ redData$age_y + redData$feed_group +
## redData$genetic_group + as.numeric(paste(redData$sample_interval)) +
## redData$mean_sun_hours_Q4 + (1 | redData$recoded_id)
##
## REML criterion at convergence: -624.2
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.7527 -0.7024 0.0083 0.6710 3.2336
##
## Random effects:
## Groups Name Variance Std.Dev.
## redData$recoded_id (Intercept) 0.00000 0.0000
## Residual 0.02982 0.1727
## Number of obs: 1019, groups: redData$recoded_id, 305
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) -1.027e-01 3.055e-02 1.012e+03
## redData$age_y 3.147e-02 4.308e-03 1.012e+03
## redData$feed_group2 -1.221e-02 1.212e-02 1.012e+03
## redData$feed_groupNULL -1.332e-02 1.548e-02 1.012e+03
## redData$genetic_groupS -1.237e-02 1.136e-02 1.012e+03
## as.numeric(paste(redData$sample_interval)) 2.360e-06 5.162e-05 1.012e+03
## redData$mean_sun_hours_Q4 1.048e-04 4.262e-04 1.012e+03
## t value Pr(>|t|)
## (Intercept) -3.362 0.000802 ***
## redData$age_y 7.306 5.58e-13 ***
## redData$feed_group2 -1.007 0.313945
## redData$feed_groupNULL -0.860 0.389808
## redData$genetic_groupS -1.089 0.276449
## as.numeric(paste(redData$sample_interval)) 0.046 0.963539
## redData$mean_sun_hours_Q4 0.246 0.805841
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) rdDt$_ rdD$_2 rD$_NU rdD$_S a.((D$
## redData$g_y -0.305
## rdDt$fd_gr2 -0.189 -0.092
## rdDt$f_NULL -0.150 0.065 0.377
## rdDt$gntc_S -0.230 0.039 -0.025 0.236
## as.n((D$_)) -0.546 -0.189 0.052 -0.049 0.057
## rdDt$m___Q4 -0.654 0.124 -0.010 -0.059 -0.004 -0.064
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
anova(sh_wi)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value
## redData$age_y 1.59194 1.59194 1 1012 53.3768
## redData$feed_group 0.03831 0.01916 2 1012 0.6423
## redData$genetic_group 0.03536 0.03536 1 1012 1.1857
## as.numeric(paste(redData$sample_interval)) 0.00006 0.00006 1 1012 0.0021
## redData$mean_sun_hours_Q4 0.00180 0.00180 1 1012 0.0604
## Pr(>F)
## redData$age_y 5.575e-13 ***
## redData$feed_group 0.5263
## redData$genetic_group 0.2764
## as.numeric(paste(redData$sample_interval)) 0.9635
## redData$mean_sun_hours_Q4 0.8058
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AIC(sh_wi)
## [1] -606.1913
Air Frost
# spring
sp_af_sp <- lmer(as.numeric(paste(redData$diff_rltl_res)) ~
redData$age_y +
redData$feed_group +
redData$genetic_group +
as.numeric(paste(redData$sample_interval)) +
redData$sum_airFrost_days_Q1 +
(1 | redData$recoded_id), na.action = na.exclude)
## boundary (singular) fit: see ?isSingular
summary(sp_af_sp)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## as.numeric(paste(redData$diff_rltl_res)) ~ redData$age_y + redData$feed_group +
## redData$genetic_group + as.numeric(paste(redData$sample_interval)) +
## redData$sum_airFrost_days_Q1 + (1 | redData$recoded_id)
##
## REML criterion at convergence: -625.3
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.7992 -0.7015 0.0145 0.6820 3.1925
##
## Random effects:
## Groups Name Variance Std.Dev.
## redData$recoded_id (Intercept) 0.00000 0.0000
## Residual 0.02979 0.1726
## Number of obs: 1019, groups: redData$recoded_id, 305
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) -1.223e-01 3.104e-02 1.012e+03
## redData$age_y 3.268e-02 4.420e-03 1.012e+03
## redData$feed_group2 -1.230e-02 1.211e-02 1.012e+03
## redData$feed_groupNULL -1.279e-02 1.545e-02 1.012e+03
## redData$genetic_groupS -1.196e-02 1.135e-02 1.012e+03
## as.numeric(paste(redData$sample_interval)) 6.478e-06 5.155e-05 1.012e+03
## redData$sum_airFrost_days_Q1 4.594e-04 3.885e-04 1.012e+03
## t value Pr(>|t|)
## (Intercept) -3.941 8.67e-05 ***
## redData$age_y 7.395 2.97e-13 ***
## redData$feed_group2 -1.016 0.310
## redData$feed_groupNULL -0.828 0.408
## redData$genetic_groupS -1.053 0.292
## as.numeric(paste(redData$sample_interval)) 0.126 0.900
## redData$sum_airFrost_days_Q1 1.182 0.237
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) rdDt$_ rdD$_2 rD$_NU rdD$_S a.((D$
## redData$g_y -0.386
## rdDt$fd_gr2 -0.187 -0.091
## rdDt$f_NULL -0.196 0.074 0.376
## rdDt$gntc_S -0.248 0.046 -0.025 0.237
## as.n((D$_)) -0.614 -0.162 0.051 -0.052 0.058
## rdDt$_F__Q1 -0.668 0.257 -0.008 0.017 0.030 0.054
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
anova(sp_af_sp)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value
## redData$age_y 1.62864 1.62864 1 1012 54.6795
## redData$feed_group 0.03763 0.01881 2 1012 0.6316
## redData$genetic_group 0.03304 0.03304 1 1012 1.1094
## as.numeric(paste(redData$sample_interval)) 0.00047 0.00047 1 1012 0.0158
## redData$sum_airFrost_days_Q1 0.04165 0.04165 1 1012 1.3983
## Pr(>F)
## redData$age_y 2.971e-13 ***
## redData$feed_group 0.5319
## redData$genetic_group 0.2925
## as.numeric(paste(redData$sample_interval)) 0.9000
## redData$sum_airFrost_days_Q1 0.2373
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AIC(sp_af_sp)
## [1] -607.344
# summer
su_af_sp <- lmer(as.numeric(paste(redData$diff_rltl_res)) ~
redData$age_y +
redData$feed_group +
redData$genetic_group +
as.numeric(paste(redData$sample_interval)) +
redData$sum_airFrost_days_Q2 +
(1 | redData$recoded_id),
na.action = na.exclude)
## boundary (singular) fit: see ?isSingular
summary(su_af_sp)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## as.numeric(paste(redData$diff_rltl_res)) ~ redData$age_y + redData$feed_group +
## redData$genetic_group + as.numeric(paste(redData$sample_interval)) +
## redData$sum_airFrost_days_Q2 + (1 | redData$recoded_id)
##
## REML criterion at convergence: -626.4
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.7529 -0.6977 0.0072 0.6732 3.2338
##
## Random effects:
## Groups Name Variance Std.Dev.
## redData$recoded_id (Intercept) 0.00000 0.0000
## Residual 0.02983 0.1727
## Number of obs: 1019, groups: redData$recoded_id, 305
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) -9.882e-02 2.424e-02 1.012e+03
## redData$age_y 3.100e-02 4.895e-03 1.012e+03
## redData$feed_group2 -1.215e-02 1.212e-02 1.012e+03
## redData$feed_groupNULL -1.333e-02 1.554e-02 1.012e+03
## redData$genetic_groupS -1.246e-02 1.138e-02 1.012e+03
## as.numeric(paste(redData$sample_interval)) 1.986e-06 5.220e-05 1.012e+03
## redData$sum_airFrost_days_Q2 1.891e-04 1.345e-03 1.012e+03
## t value Pr(>|t|)
## (Intercept) -4.077 4.92e-05 ***
## redData$age_y 6.334 3.58e-10 ***
## redData$feed_group2 -1.002 0.316
## redData$feed_groupNULL -0.858 0.391
## redData$genetic_groupS -1.095 0.274
## as.numeric(paste(redData$sample_interval)) 0.038 0.970
## redData$sum_airFrost_days_Q2 0.141 0.888
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) rdDt$_ rdD$_2 rD$_NU rdD$_S a.((D$
## redData$g_y -0.101
## rdDt$fd_gr2 -0.252 -0.089
## rdDt$f_NULL -0.203 0.116 0.372
## rdDt$gntc_S -0.271 0.068 -0.026 0.242
## as.n((D$_)) -0.683 -0.079 0.048 -0.035 0.067
## rdDt$_F__Q2 -0.301 -0.487 0.019 -0.108 -0.067 -0.162
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
anova(su_af_sp)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value
## redData$age_y 1.19672 1.19672 1 1012 40.1236
## redData$feed_group 0.03808 0.01904 2 1012 0.6384
## redData$genetic_group 0.03576 0.03576 1 1012 1.1990
## as.numeric(paste(redData$sample_interval)) 0.00004 0.00004 1 1012 0.0014
## redData$sum_airFrost_days_Q2 0.00059 0.00059 1 1012 0.0198
## Pr(>F)
## redData$age_y 3.58e-10 ***
## redData$feed_group 0.5283
## redData$genetic_group 0.2738
## as.numeric(paste(redData$sample_interval)) 0.9697
## redData$sum_airFrost_days_Q2 0.8883
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AIC(su_af_sp)
## [1] -608.4493
# autumn
au_af_sp <- lmer(as.numeric(paste(redData$diff_rltl_res)) ~
redData$age_y +
redData$feed_group +
redData$genetic_group +
as.numeric(paste(redData$sample_interval)) +
redData$sum_airFrost_days_Q3 +
(1 | redData$recoded_id),
na.action = na.exclude)
## boundary (singular) fit: see ?isSingular
summary(au_af_sp)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## as.numeric(paste(redData$diff_rltl_res)) ~ redData$age_y + redData$feed_group +
## redData$genetic_group + as.numeric(paste(redData$sample_interval)) +
## redData$sum_airFrost_days_Q3 + (1 | redData$recoded_id)
##
## REML criterion at convergence: -633.1
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.7572 -0.7028 0.0207 0.6639 3.2397
##
## Random effects:
## Groups Name Variance Std.Dev.
## redData$recoded_id (Intercept) 0.0000 0.0000
## Residual 0.0297 0.1723
## Number of obs: 1019, groups: redData$recoded_id, 305
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) -1.088e-01 2.366e-02 1.012e+03
## redData$age_y 3.166e-02 4.268e-03 1.012e+03
## redData$feed_group2 -1.204e-02 1.209e-02 1.012e+03
## redData$feed_groupNULL -1.383e-02 1.542e-02 1.012e+03
## redData$genetic_groupS -1.213e-02 1.133e-02 1.012e+03
## as.numeric(paste(redData$sample_interval)) 4.813e-06 5.141e-05 1.012e+03
## redData$sum_airFrost_days_Q3 9.125e-03 4.374e-03 1.012e+03
## t value Pr(>|t|)
## (Intercept) -4.600 4.77e-06 ***
## redData$age_y 7.419 2.50e-13 ***
## redData$feed_group2 -0.996 0.3195
## redData$feed_groupNULL -0.897 0.3701
## redData$genetic_groupS -1.070 0.2847
## as.numeric(paste(redData$sample_interval)) 0.094 0.9254
## redData$sum_airFrost_days_Q3 2.086 0.0372 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) rdDt$_ rdD$_2 rD$_NU rdD$_S a.((D$
## redData$g_y -0.298
## rdDt$fd_gr2 -0.253 -0.091
## rdDt$f_NULL -0.237 0.072 0.376
## rdDt$gntc_S -0.301 0.040 -0.025 0.236
## as.n((D$_)) -0.762 -0.182 0.052 -0.053 0.057
## rdDt$_F__Q3 -0.224 0.036 0.005 -0.023 0.009 0.015
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
anova(au_af_sp)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value
## redData$age_y 1.63465 1.63465 1 1012 55.0413
## redData$feed_group 0.03888 0.01944 2 1012 0.6545
## redData$genetic_group 0.03403 0.03403 1 1012 1.1459
## as.numeric(paste(redData$sample_interval)) 0.00026 0.00026 1 1012 0.0088
## redData$sum_airFrost_days_Q3 0.12927 0.12927 1 1012 4.3529
## Pr(>F)
## redData$age_y 2.495e-13 ***
## redData$feed_group 0.5199
## redData$genetic_group 0.2847
## as.numeric(paste(redData$sample_interval)) 0.9254
## redData$sum_airFrost_days_Q3 0.0372 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AIC(au_af_sp)
## [1] -615.1354
tableS24 <- as.data.frame(round(coef(summary(au_af_sp)), 3))
tableS24
## Estimate Std. Error df t value
## (Intercept) -0.109 0.024 1012 -4.600
## redData$age_y 0.032 0.004 1012 7.419
## redData$feed_group2 -0.012 0.012 1012 -0.996
## redData$feed_groupNULL -0.014 0.015 1012 -0.897
## redData$genetic_groupS -0.012 0.011 1012 -1.070
## as.numeric(paste(redData$sample_interval)) 0.000 0.000 1012 0.094
## redData$sum_airFrost_days_Q3 0.009 0.004 1012 2.086
## Pr(>|t|)
## (Intercept) 0.000
## redData$age_y 0.000
## redData$feed_group2 0.319
## redData$feed_groupNULL 0.370
## redData$genetic_groupS 0.285
## as.numeric(paste(redData$sample_interval)) 0.925
## redData$sum_airFrost_days_Q3 0.037
tableS25 <- as.data.frame(anova(au_af_sp))
tableS25
## Sum Sq Mean Sq NumDF
## redData$age_y 1.6346511363 1.6346511363 1
## redData$feed_group 0.0388776419 0.0194388210 2
## redData$genetic_group 0.0340323371 0.0340323371 1
## as.numeric(paste(redData$sample_interval)) 0.0002603224 0.0002603224 1
## redData$sum_airFrost_days_Q3 0.1292737565 0.1292737565 1
## DenDF F value Pr(>F)
## redData$age_y 1012 55.041277759 2.495077e-13
## redData$feed_group 1012 0.654535711 5.199031e-01
## redData$genetic_group 1012 1.145922378 2.846596e-01
## as.numeric(paste(redData$sample_interval)) 1012 0.008765466 9.254263e-01
## redData$sum_airFrost_days_Q3 1012 4.352850941 3.719694e-02
# winter
wi_af_sp <- lmer(as.numeric(paste(redData$diff_rltl_res)) ~
redData$age_y +
redData$feed_group +
redData$genetic_group +
as.numeric(paste(redData$sample_interval)) +
redData$sum_airFrost_days_Q4 +
(1 | redData$recoded_id),
na.action = na.exclude)
## boundary (singular) fit: see ?isSingular
summary(wi_af_sp)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## as.numeric(paste(redData$diff_rltl_res)) ~ redData$age_y + redData$feed_group +
## redData$genetic_group + as.numeric(paste(redData$sample_interval)) +
## redData$sum_airFrost_days_Q4 + (1 | redData$recoded_id)
##
## REML criterion at convergence: -624.5
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.7568 -0.7014 0.0075 0.6697 3.2300
##
## Random effects:
## Groups Name Variance Std.Dev.
## redData$recoded_id (Intercept) 0.00000 0.0000
## Residual 0.02983 0.1727
## Number of obs: 1019, groups: redData$recoded_id, 305
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) -1.005e-01 2.915e-02 1.012e+03
## redData$age_y 3.152e-02 4.438e-03 1.012e+03
## redData$feed_group2 -1.221e-02 1.212e-02 1.012e+03
## redData$feed_groupNULL -1.319e-02 1.547e-02 1.012e+03
## redData$genetic_groupS -1.234e-02 1.136e-02 1.012e+03
## as.numeric(paste(redData$sample_interval)) 2.889e-06 5.155e-05 1.012e+03
## redData$sum_airFrost_days_Q4 7.905e-05 5.171e-04 1.012e+03
## t value Pr(>|t|)
## (Intercept) -3.448 0.000587 ***
## redData$age_y 7.103 2.29e-12 ***
## redData$feed_group2 -1.007 0.313937
## redData$feed_groupNULL -0.853 0.393961
## redData$genetic_groupS -1.086 0.277655
## as.numeric(paste(redData$sample_interval)) 0.056 0.955313
## redData$sum_airFrost_days_Q4 0.153 0.878525
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) rdDt$_ rdD$_2 rD$_NU rdD$_S a.((D$
## redData$g_y -0.391
## rdDt$fd_gr2 -0.194 -0.093
## rdDt$f_NULL -0.173 0.059 0.377
## rdDt$gntc_S -0.250 0.042 -0.025 0.236
## as.n((D$_)) -0.595 -0.186 0.052 -0.052 0.056
## rdDt$_F__Q4 -0.609 0.269 -0.017 -0.040 0.011 -0.036
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
anova(wi_af_sp)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value
## redData$age_y 1.50490 1.50490 1 1012 50.4566
## redData$feed_group 0.03805 0.01903 2 1012 0.6379
## redData$genetic_group 0.03519 0.03519 1 1012 1.1798
## as.numeric(paste(redData$sample_interval)) 0.00009 0.00009 1 1012 0.0031
## redData$sum_airFrost_days_Q4 0.00070 0.00070 1 1012 0.0234
## Pr(>F)
## redData$age_y 2.294e-12 ***
## redData$feed_group 0.5286
## redData$genetic_group 0.2777
## as.numeric(paste(redData$sample_interval)) 0.9553
## redData$sum_airFrost_days_Q4 0.8785
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
AIC(wi_af_sp)
## [1] -606.5407
shapiro.test(init_change_dat$ResDiff)
##
## Shapiro-Wilk normality test
##
## data: init_change_dat$ResDiff
## W = 0.99401, p-value = 0.3057
ks.test(init_change_dat$ResDiff, pnorm)
##
## One-sample Kolmogorov-Smirnov test
##
## data: init_change_dat$ResDiff
## D = 0.39675, p-value < 2.2e-16
## alternative hypothesis: two-sided
qqnorm(init_change_dat$ResDiff)
coxFit <- coxph(Surv(as.numeric(paste(init_change_dat$TimeMeasure)),
init_change_dat$Event == 1) ~ init_change_dat$ResDiff)
summary(coxFit)
## Call:
## coxph(formula = Surv(as.numeric(paste(init_change_dat$TimeMeasure)),
## init_change_dat$Event == 1) ~ init_change_dat$ResDiff)
##
## n= 291, number of events= 227
##
## coef exp(coef) se(coef) z Pr(>|z|)
## init_change_dat$ResDiff -1.1406 0.3196 0.3914 -2.914 0.00356 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## exp(coef) exp(-coef) lower .95 upper .95
## init_change_dat$ResDiff 0.3196 3.129 0.1484 0.6883
##
## Concordance= 0.554 (se = 0.021 )
## Likelihood ratio test= 8.32 on 1 df, p=0.004
## Wald test = 8.49 on 1 df, p=0.004
## Score (logrank) test = 8.48 on 1 df, p=0.004
tert_p_1 <- ggplot(
init_change_dat,
aes(
x = as.factor(init_change_dat$ResDiff_3G),
y = init_change_dat$ResDiff,
colour = as.factor(init_change_dat$ResDiff_3G)
)
) +
geom_boxplot() +
xlab("RLTL change tertiles") +
ylab("RLTL change") +
theme_classic(20) +
geom_jitter() +
scale_color_manual(values = mycoloursP[16:40]) +
theme(legend.position = "none")
tert_p_1
## Warning: Use of `init_change_dat$ResDiff_3G` is discouraged. Use `ResDiff_3G`
## instead.
## Warning: Use of `init_change_dat$ResDiff` is discouraged. Use `ResDiff` instead.
## Warning: Use of `init_change_dat$ResDiff_3G` is discouraged. Use `ResDiff_3G`
## instead.
## Warning: Use of `init_change_dat$ResDiff_3G` is discouraged. Use `ResDiff_3G`
## instead.
## Warning: Use of `init_change_dat$ResDiff` is discouraged. Use `ResDiff` instead.
## Warning: Use of `init_change_dat$ResDiff_3G` is discouraged. Use `ResDiff_3G`
## instead.
init_ch_plot
coxFit <- coxph(Surv(init_change_dat$TimeMeasure,
init_change_dat$Event == 1) ~
init_change_dat$ResDiff_3G)
summary(coxFit)
## Call:
## coxph(formula = Surv(init_change_dat$TimeMeasure, init_change_dat$Event ==
## 1) ~ init_change_dat$ResDiff_3G)
##
## n= 291, number of events= 227
##
## coef exp(coef) se(coef) z Pr(>|z|)
## init_change_dat$ResDiff_3G -0.2259 0.7978 0.0820 -2.755 0.00586 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## exp(coef) exp(-coef) lower .95 upper .95
## init_change_dat$ResDiff_3G 0.7978 1.253 0.6793 0.9369
##
## Concordance= 0.55 (se = 0.02 )
## Likelihood ratio test= 7.61 on 1 df, p=0.006
## Wald test = 7.59 on 1 df, p=0.006
## Score (logrank) test = 7.65 on 1 df, p=0.006
spaghettiData <- read.csv(here::here("data", "RC_SpaghettiData.csv"))
spaghettiData$recoded_id <- as.factor(paste(spaghettiData$recoded_id))
ggplot(data = spaghettiData, aes(
x = age_y,
y = residual_rltl_t,
group = recoded_id,
colour = recoded_id
)) +
geom_point() +
geom_line() +
facet_wrap(. ~ recoded_id, ncol = 5) +
xlab("Age in years") +
ylab("RLTL residuals") +
theme_bw() +
scale_color_manual(values = mycoloursP[16:40])
year_p <- ggplot(
data = data,
aes(
x = sample_year,
y = residual_rltl_t,
group = recoded_id,
colour = as.factor(data$recoded_id)
)
) +
geom_point() +
geom_line() +
xlab("Sample Year") +
ylab("RLTL residuals") +
theme_classic() +
theme(legend.position = "none")
age_p <- ggplot(
data = data,
aes(
x = age_y,
y = residual_rltl_t,
group = recoded_id,
colour = as.factor(data$recoded_id)
)
) +
geom_point() +
geom_line() +
xlab("Age in years") +
ylab("RLTL residuals") +
theme_classic() +
theme(legend.position = "none")
grid.arrange(age_p, year_p, ncol = 2)
## Warning: Use of `data$recoded_id` is discouraged. Use `recoded_id` instead.
## Warning: Use of `data$recoded_id` is discouraged. Use `recoded_id` instead.
## Warning: Use of `data$recoded_id` is discouraged. Use `recoded_id` instead.
## Warning: Use of `data$recoded_id` is discouraged. Use `recoded_id` instead.
# average_resid rltl_change abs_rltl_change MeanChangeRate MeanChangeRateAbs
# 1)
x <- 15
AverRes <- uDeadData$average_resid
chF <- uDeadData$rltl_change
df1 <- data.frame(AverRes, chF)
cor.test(AverRes, chF)
##
## Pearson's product-moment correlation
##
## data: AverRes and chF
## t = -3.0223, df = 239, p-value = 0.002782
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.31069811 -0.06712564
## sample estimates:
## cor
## -0.1918646
CorP1 <- ggplot(df1, aes(x = AverRes, y = chF)) +
geom_point(size = 2) +
labs(x = "Mean RLTL", y = "Mean RLTL change") +
stat_smooth(method = lm, formula = y ~ x) +
theme_bw(x)
# CorP1
# 2)
AchF <- uDeadData$abs_rltl_change
df2 <- data.frame(AverRes, AchF)
cor.test(AverRes, AchF)
##
## Pearson's product-moment correlation
##
## data: AverRes and AchF
## t = 4.9383, df = 239, p-value = 1.48e-06
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## 0.185034 0.414706
## sample estimates:
## cor
## 0.3042856
CorP2 <- ggplot(df2, aes(x = AverRes, y = AchF)) +
geom_point(size = 2) +
labs(x = "Mean RLTL", y = "Mean absolute RLTL change") +
stat_smooth(method = lm, formula = y ~ x) +
theme_bw(x)
CorP2
# 5)
df5 <- data.frame(chF, AchF)
cor.test(chF, AchF)
##
## Pearson's product-moment correlation
##
## data: chF and AchF
## t = -9.7941, df = 239, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.6196323 -0.4384552
## sample estimates:
## cor
## -0.53517
CorP5 <- ggplot(df5, aes(x = chF, y = AchF)) +
geom_point(size = 2) +
labs(x = "Mean RLTL change", y = "Mean absolute RLTL change") +
theme_bw(x) +
stat_smooth(method = lm, formula = y ~ x) +
geom_vline(xintercept = 0, linetype = "dotted") +
geom_abline(intercept = 0, slope = -1, colour = "red") +
geom_abline(intercept = 0, slope = 1, colour = "blue")
# CorP5
grid.arrange(CorP1, CorP2, CorP5, ncol = 3)
Age with reference year 0
# Age in years as factor with reference year being 0 (Age at t-1)
mod1f <- lmer(as.numeric(paste(redData$diff_rltl_res)) ~
as.factor(redData$age_y) +
redData$sample_year +
as.numeric(paste(redData$sample_interval)) +
redData$feed_group +
redData$genetic_group +
(1 | redData$recoded_id),
na.action = na.exclude)
## boundary (singular) fit: see ?isSingular
summary(mod1f)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: as.numeric(paste(redData$diff_rltl_res)) ~ as.factor(redData$age_y) +
## redData$sample_year + as.numeric(paste(redData$sample_interval)) +
## redData$feed_group + redData$genetic_group + (1 | redData$recoded_id)
##
## REML criterion at convergence: -650
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.5593 -0.6841 0.0276 0.6922 3.5944
##
## Random effects:
## Groups Name Variance Std.Dev.
## redData$recoded_id (Intercept) 2.964e-17 5.444e-09
## Residual 2.867e-02 1.693e-01
## Number of obs: 1019, groups: redData$recoded_id, 305
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) -1.557e+01 1.224e+01 1.007e+03
## as.factor(redData$age_y)1 4.027e-02 7.165e-02 1.007e+03
## as.factor(redData$age_y)2 1.399e-01 7.190e-02 1.007e+03
## as.factor(redData$age_y)3 1.545e-01 7.271e-02 1.007e+03
## as.factor(redData$age_y)4 1.355e-01 7.411e-02 1.007e+03
## as.factor(redData$age_y)5 1.634e-01 7.677e-02 1.007e+03
## as.factor(redData$age_y)6 1.076e-01 8.193e-02 1.007e+03
## redData$sample_year 7.674e-03 6.088e-03 1.007e+03
## as.numeric(paste(redData$sample_interval)) -2.006e-05 5.256e-05 1.007e+03
## redData$feed_group2 -9.068e-03 1.192e-02 1.007e+03
## redData$feed_groupNULL -1.064e-02 1.523e-02 1.007e+03
## redData$genetic_groupS -1.437e-02 1.117e-02 1.007e+03
## t value Pr(>|t|)
## (Intercept) -1.272 0.2038
## as.factor(redData$age_y)1 0.562 0.5742
## as.factor(redData$age_y)2 1.946 0.0520 .
## as.factor(redData$age_y)3 2.125 0.0338 *
## as.factor(redData$age_y)4 1.829 0.0678 .
## as.factor(redData$age_y)5 2.128 0.0336 *
## as.factor(redData$age_y)6 1.313 0.1894
## redData$sample_year 1.261 0.2078
## as.numeric(paste(redData$sample_interval)) -0.382 0.7027
## redData$feed_group2 -0.761 0.4468
## redData$feed_groupNULL -0.698 0.4852
## redData$genetic_groupS -1.286 0.1986
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) a.(D$_)1 a.(D$_)2 a.(D$_)3 a.(D$_)4 a.(D$_)5 a.(D$_)6 rdDt$_
## as.fc(D$_)1 -0.028
## as.fc(D$_)2 0.050 0.977
## as.fc(D$_)3 0.115 0.968 0.976
## as.fc(D$_)4 0.157 0.954 0.965 0.969
## as.fc(D$_)5 0.185 0.921 0.935 0.940 0.937
## as.fc(D$_)6 0.190 0.850 0.864 0.870 0.866 0.844
## rdDt$smpl_y -1.000 0.022 -0.056 -0.121 -0.162 -0.190 -0.194
## as.n((D$_)) 0.096 -0.218 -0.217 -0.220 -0.236 -0.225 -0.146 -0.096
## rdDt$fd_gr2 -0.042 -0.035 -0.041 -0.043 -0.051 -0.064 -0.079 0.042
## rdDt$f_NULL 0.086 0.024 0.041 0.052 0.051 0.051 0.064 -0.087
## rdDt$gntc_S 0.072 0.028 0.033 0.042 0.042 0.049 0.059 -0.072
## a.((D$ rdD$_2 rD$_NU
## as.fc(D$_)1
## as.fc(D$_)2
## as.fc(D$_)3
## as.fc(D$_)4
## as.fc(D$_)5
## as.fc(D$_)6
## rdDt$smpl_y
## as.n((D$_))
## rdDt$fd_gr2 0.045
## rdDt$f_NULL -0.044 0.370
## rdDt$gntc_S 0.060 -0.030 0.242
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
anova(mod1f)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value
## as.factor(redData$age_y) 1.58118 0.263529 6 1007 9.1926
## redData$sample_year 0.04555 0.045550 1 1007 1.5889
## as.numeric(paste(redData$sample_interval)) 0.00418 0.004177 1 1007 0.1457
## redData$feed_group 0.02237 0.011183 2 1007 0.3901
## redData$genetic_group 0.04744 0.047438 1 1007 1.6547
## Pr(>F)
## as.factor(redData$age_y) 8.079e-10 ***
## redData$sample_year 0.2078
## as.numeric(paste(redData$sample_interval)) 0.7027
## redData$feed_group 0.6771
## redData$genetic_group 0.1986
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Log likelihod ratio test to see if animal is significant as random effect
redData$R_age_y <- as.factor(redData$age_y)
# lm without random effect to do likelihood ratio test
modLM <- glm(as.numeric(paste(redData$diff_rltl_res)) ~
as.factor(redData$age_y) +
redData$sample_year +
as.numeric(paste(redData$sample_interval)) +
redData$feed_group +
redData$genetic_group)
anova(mod1f, modLM)
## refitting model(s) with ML (instead of REML)
## Data: NULL
## Models:
## modLM: as.numeric(paste(redData$diff_rltl_res)) ~ as.factor(redData$age_y) +
## modLM: redData$sample_year + as.numeric(paste(redData$sample_interval)) +
## modLM: redData$feed_group + redData$genetic_group
## mod1f: as.numeric(paste(redData$diff_rltl_res)) ~ as.factor(redData$age_y) +
## mod1f: redData$sample_year + as.numeric(paste(redData$sample_interval)) +
## mod1f: redData$feed_group + redData$genetic_group + (1 | redData$recoded_id)
## npar AIC BIC logLik deviance Chisq Df Pr(>Chisq)
## modLM 13 -713.75 -649.71 369.88 -739.75
## mod1f 14 -711.75 -642.78 369.88 -739.75 0 1 1
logLik(mod1f)
## 'log Lik.' 324.9983 (df=14)
logLik(modLM)
## 'log Lik.' 369.876 (df=13)
Animal ID is not significant as random effect.
# Age in years as factor with reference year being 1 (Age at t-1)
redData$age_y <- as.factor(redData$age_y)
contrasts(redData$age_y) <- contr.treatment(levels(redData$age_y),
base = which(levels(redData$age_y) == "1"))
mod1f <- lmer(as.numeric(paste(redData$diff_rltl_res)) ~
as.factor(redData$age_y) +
redData$sample_year +
as.numeric(paste(redData$sample_interval)) +
redData$feed_group +
redData$genetic_group +
(1 | redData$recoded_id),
na.action = na.exclude)
## boundary (singular) fit: see ?isSingular
summary(mod1f)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: as.numeric(paste(redData$diff_rltl_res)) ~ as.factor(redData$age_y) +
## redData$sample_year + as.numeric(paste(redData$sample_interval)) +
## redData$feed_group + redData$genetic_group + (1 | redData$recoded_id)
##
## REML criterion at convergence: -650
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.5593 -0.6841 0.0276 0.6922 3.5944
##
## Random effects:
## Groups Name Variance Std.Dev.
## redData$recoded_id (Intercept) 6.229e-18 2.496e-09
## Residual 2.867e-02 1.693e-01
## Number of obs: 1019, groups: redData$recoded_id, 305
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) -1.553e+01 1.224e+01 1.007e+03
## as.factor(redData$age_y)0 -4.027e-02 7.165e-02 1.007e+03
## as.factor(redData$age_y)2 9.962e-02 1.530e-02 1.007e+03
## as.factor(redData$age_y)3 1.143e-01 1.837e-02 1.007e+03
## as.factor(redData$age_y)4 9.524e-02 2.225e-02 1.007e+03
## as.factor(redData$age_y)5 1.231e-01 2.997e-02 1.007e+03
## as.factor(redData$age_y)6 6.731e-02 4.322e-02 1.007e+03
## redData$sample_year 7.674e-03 6.088e-03 1.007e+03
## as.numeric(paste(redData$sample_interval)) -2.006e-05 5.256e-05 1.007e+03
## redData$feed_group2 -9.068e-03 1.192e-02 1.007e+03
## redData$feed_groupNULL -1.064e-02 1.523e-02 1.007e+03
## redData$genetic_groupS -1.437e-02 1.117e-02 1.007e+03
## t value Pr(>|t|)
## (Intercept) -1.269 0.205
## as.factor(redData$age_y)0 -0.562 0.574
## as.factor(redData$age_y)2 6.509 1.19e-10 ***
## as.factor(redData$age_y)3 6.221 7.25e-10 ***
## as.factor(redData$age_y)4 4.280 2.05e-05 ***
## as.factor(redData$age_y)5 4.107 4.33e-05 ***
## as.factor(redData$age_y)6 1.558 0.120
## redData$sample_year 1.261 0.208
## as.numeric(paste(redData$sample_interval)) -0.382 0.703
## redData$feed_group2 -0.761 0.447
## redData$feed_groupNULL -0.698 0.485
## redData$genetic_groupS -1.286 0.199
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) a.(D$_)0 a.(D$_)2 a.(D$_)3 a.(D$_)4 a.(D$_)5 a.(D$_)6 rdDt$_
## as.fc(D$_)0 0.022
## as.fc(D$_)2 0.364 0.091
## as.fc(D$_)3 0.563 0.070 0.567
## as.fc(D$_)4 0.610 0.043 0.524 0.603
## as.fc(D$_)5 0.540 0.032 0.422 0.498 0.499
## as.fc(D$_)6 0.405 0.047 0.303 0.357 0.350 0.299
## rdDt$smpl_y -1.000 -0.022 -0.365 -0.564 -0.611 -0.541 -0.405
## as.n((D$_)) 0.095 0.218 0.001 -0.020 -0.085 -0.055 0.085 -0.096
## rdDt$fd_gr2 -0.042 0.035 -0.031 -0.036 -0.057 -0.081 -0.091 0.042
## rdDt$f_NULL 0.086 -0.024 0.079 0.111 0.093 0.073 0.081 -0.087
## rdDt$gntc_S 0.072 -0.028 0.022 0.057 0.050 0.058 0.064 -0.072
## a.((D$ rdD$_2 rD$_NU
## as.fc(D$_)0
## as.fc(D$_)2
## as.fc(D$_)3
## as.fc(D$_)4
## as.fc(D$_)5
## as.fc(D$_)6
## rdDt$smpl_y
## as.n((D$_))
## rdDt$fd_gr2 0.045
## rdDt$f_NULL -0.044 0.370
## rdDt$gntc_S 0.060 -0.030 0.242
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
anova(mod1f)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value
## as.factor(redData$age_y) 1.58118 0.263529 6 1007 9.1926
## redData$sample_year 0.04555 0.045550 1 1007 1.5889
## as.numeric(paste(redData$sample_interval)) 0.00418 0.004177 1 1007 0.1457
## redData$feed_group 0.02237 0.011183 2 1007 0.3901
## redData$genetic_group 0.04744 0.047438 1 1007 1.6547
## Pr(>F)
## as.factor(redData$age_y) 8.079e-10 ***
## redData$sample_year 0.2078
## as.numeric(paste(redData$sample_interval)) 0.7027
## redData$feed_group 0.6771
## redData$genetic_group 0.1986
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Age in years as factor with reference year being 1 (Age at t-1)
redData$age_y <- as.factor(redData$age_y)
contrasts(redData$age_y) <- contr.treatment(levels(redData$age_y),
base = which(levels(redData$age_y) == "1"))
mod2f <- lmer(as.numeric(paste(redData$diff_rltl_res)) ~
as.factor(redData$age_y) +
#redData$sample_year +
#as.numeric(paste(redData$sample_interval)) +
(1 | redData$recoded_id),
na.action = na.exclude)
## boundary (singular) fit: see ?isSingular
summary(mod2f)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: as.numeric(paste(redData$diff_rltl_res)) ~ as.factor(redData$age_y) +
## (1 | redData$recoded_id)
##
## REML criterion at convergence: -693.4
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.6177 -0.6765 0.0386 0.6806 3.5183
##
## Random effects:
## Groups Name Variance Std.Dev.
## redData$recoded_id (Intercept) 0.00000 0.0000
## Residual 0.02863 0.1692
## Number of obs: 1019, groups: redData$recoded_id, 305
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) -1.151e-01 9.988e-03 1.012e+03 -11.528 < 2e-16 ***
## as.factor(redData$age_y)0 -3.630e-02 6.980e-02 1.012e+03 -0.520 0.6032
## as.factor(redData$age_y)2 1.063e-01 1.420e-02 1.012e+03 7.485 1.56e-13 ***
## as.factor(redData$age_y)3 1.273e-01 1.505e-02 1.012e+03 8.456 < 2e-16 ***
## as.factor(redData$age_y)4 1.114e-01 1.728e-02 1.012e+03 6.449 1.74e-10 ***
## as.factor(redData$age_y)5 1.422e-01 2.491e-02 1.012e+03 5.711 1.48e-08 ***
## as.factor(redData$age_y)6 8.883e-02 3.913e-02 1.012e+03 2.270 0.0234 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) a.(D$_)0 a.(D$_)2 a.(D$_)3 a.(D$_)4 a.(D$_)5
## as.fc(D$_)0 -0.143
## as.fc(D$_)2 -0.703 0.101
## as.fc(D$_)3 -0.664 0.095 0.467
## as.fc(D$_)4 -0.578 0.083 0.407 0.384
## as.fc(D$_)5 -0.401 0.057 0.282 0.266 0.232
## as.fc(D$_)6 -0.255 0.037 0.180 0.169 0.148 0.102
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
anova(mod2f)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value Pr(>F)
## as.factor(redData$age_y) 2.9674 0.49456 6 1012 17.273 < 2.2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
exclude2009 <- subset(redData, redData$sample_year != "2009")
mod1f <- lmer(as.numeric(paste(exclude2009$diff_rltl_res)) ~
as.factor(exclude2009$age_y) +
exclude2009$sample_year +
as.numeric(paste(exclude2009$sample_interval)) +
exclude2009$feed_group +
exclude2009$genetic_group +
(1 | exclude2009$recoded_id), na.action = na.exclude)
## boundary (singular) fit: see ?isSingular
summary(mod1f)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## as.numeric(paste(exclude2009$diff_rltl_res)) ~ as.factor(exclude2009$age_y) +
## exclude2009$sample_year + as.numeric(paste(exclude2009$sample_interval)) +
## exclude2009$feed_group + exclude2009$genetic_group + (1 |
## exclude2009$recoded_id)
##
## REML criterion at convergence: -650
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.5593 -0.6841 0.0276 0.6922 3.5944
##
## Random effects:
## Groups Name Variance Std.Dev.
## exclude2009$recoded_id (Intercept) 6.229e-18 2.496e-09
## Residual 2.867e-02 1.693e-01
## Number of obs: 1019, groups: exclude2009$recoded_id, 305
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) -1.553e+01 1.224e+01 1.007e+03
## as.factor(exclude2009$age_y)0 -4.027e-02 7.165e-02 1.007e+03
## as.factor(exclude2009$age_y)2 9.962e-02 1.530e-02 1.007e+03
## as.factor(exclude2009$age_y)3 1.143e-01 1.837e-02 1.007e+03
## as.factor(exclude2009$age_y)4 9.524e-02 2.225e-02 1.007e+03
## as.factor(exclude2009$age_y)5 1.231e-01 2.997e-02 1.007e+03
## as.factor(exclude2009$age_y)6 6.731e-02 4.322e-02 1.007e+03
## exclude2009$sample_year 7.674e-03 6.088e-03 1.007e+03
## as.numeric(paste(exclude2009$sample_interval)) -2.006e-05 5.256e-05 1.007e+03
## exclude2009$feed_group2 -9.068e-03 1.192e-02 1.007e+03
## exclude2009$feed_groupNULL -1.064e-02 1.523e-02 1.007e+03
## exclude2009$genetic_groupS -1.437e-02 1.117e-02 1.007e+03
## t value Pr(>|t|)
## (Intercept) -1.269 0.205
## as.factor(exclude2009$age_y)0 -0.562 0.574
## as.factor(exclude2009$age_y)2 6.509 1.19e-10 ***
## as.factor(exclude2009$age_y)3 6.221 7.25e-10 ***
## as.factor(exclude2009$age_y)4 4.280 2.05e-05 ***
## as.factor(exclude2009$age_y)5 4.107 4.33e-05 ***
## as.factor(exclude2009$age_y)6 1.558 0.120
## exclude2009$sample_year 1.261 0.208
## as.numeric(paste(exclude2009$sample_interval)) -0.382 0.703
## exclude2009$feed_group2 -0.761 0.447
## exclude2009$feed_groupNULL -0.698 0.485
## exclude2009$genetic_groupS -1.286 0.199
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) a.(2009$_)0 a.(2009$_)2 a.(2009$_)3 a.(2009$_)4 a.(2009$_)5
## a.(2009$_)0 0.022
## a.(2009$_)2 0.364 0.091
## a.(2009$_)3 0.563 0.070 0.567
## a.(2009$_)4 0.610 0.043 0.524 0.603
## a.(2009$_)5 0.540 0.032 0.422 0.498 0.499
## a.(2009$_)6 0.405 0.047 0.303 0.357 0.350 0.299
## excld2009$_ -1.000 -0.022 -0.365 -0.564 -0.611 -0.541
## a.((2009$_) 0.095 0.218 0.001 -0.020 -0.085 -0.055
## excl2009$_2 -0.042 0.035 -0.031 -0.036 -0.057 -0.081
## e2009$_NULL 0.086 -0.024 0.079 0.111 0.093 0.073
## excl2009$_S 0.072 -0.028 0.022 0.057 0.050 0.058
## a.(2009$_)6 ex2009$_ a.((20 e2009$_2 e2009$_N
## a.(2009$_)0
## a.(2009$_)2
## a.(2009$_)3
## a.(2009$_)4
## a.(2009$_)5
## a.(2009$_)6
## excld2009$_ -0.405
## a.((2009$_) 0.085 -0.096
## excl2009$_2 -0.091 0.042 0.045
## e2009$_NULL 0.081 -0.087 -0.044 0.370
## excl2009$_S 0.064 -0.072 0.060 -0.030 0.242
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
anova(mod1f)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF
## as.factor(exclude2009$age_y) 1.58118 0.263529 6 1007
## exclude2009$sample_year 0.04555 0.045550 1 1007
## as.numeric(paste(exclude2009$sample_interval)) 0.00418 0.004177 1 1007
## exclude2009$feed_group 0.02237 0.011183 2 1007
## exclude2009$genetic_group 0.04744 0.047438 1 1007
## F value Pr(>F)
## as.factor(exclude2009$age_y) 9.1926 8.079e-10 ***
## exclude2009$sample_year 1.5889 0.2078
## as.numeric(paste(exclude2009$sample_interval)) 0.1457 0.7027
## exclude2009$feed_group 0.3901 0.6771
## exclude2009$genetic_group 1.6547 0.1986
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
df<-as.data.frame(round(coef(summary(mod1f)),3))
df
## Estimate Std. Error df t value
## (Intercept) -15.529 12.242 1007 -1.269
## as.factor(exclude2009$age_y)0 -0.040 0.072 1007 -0.562
## as.factor(exclude2009$age_y)2 0.100 0.015 1007 6.509
## as.factor(exclude2009$age_y)3 0.114 0.018 1007 6.221
## as.factor(exclude2009$age_y)4 0.095 0.022 1007 4.280
## as.factor(exclude2009$age_y)5 0.123 0.030 1007 4.107
## as.factor(exclude2009$age_y)6 0.067 0.043 1007 1.558
## exclude2009$sample_year 0.008 0.006 1007 1.261
## as.numeric(paste(exclude2009$sample_interval)) 0.000 0.000 1007 -0.382
## exclude2009$feed_group2 -0.009 0.012 1007 -0.761
## exclude2009$feed_groupNULL -0.011 0.015 1007 -0.698
## exclude2009$genetic_groupS -0.014 0.011 1007 -1.286
## Pr(>|t|)
## (Intercept) 0.205
## as.factor(exclude2009$age_y)0 0.574
## as.factor(exclude2009$age_y)2 0.000
## as.factor(exclude2009$age_y)3 0.000
## as.factor(exclude2009$age_y)4 0.000
## as.factor(exclude2009$age_y)5 0.000
## as.factor(exclude2009$age_y)6 0.120
## exclude2009$sample_year 0.208
## as.numeric(paste(exclude2009$sample_interval)) 0.703
## exclude2009$feed_group2 0.447
## exclude2009$feed_groupNULL 0.485
## exclude2009$genetic_groupS 0.199
#Age in years as factor with reference year being 2 (Age at t-1)
contrasts(redData$R_age_y) <- contr.treatment(levels(redData$R_age_y),
base=which(levels(redData$R_age_y) == '2'))
mod1f<-lmer(as.numeric(paste(redData$diff_rltl_res)) ~
as.factor(redData$age_y) +
redData$sample_year +
as.numeric(paste(redData$sample_interval)) +
redData$feed_group +
redData$genetic_group +
(1|redData$recoded_id), na.action=na.exclude)
## boundary (singular) fit: see ?isSingular
summary(mod1f)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: as.numeric(paste(redData$diff_rltl_res)) ~ as.factor(redData$age_y) +
## redData$sample_year + as.numeric(paste(redData$sample_interval)) +
## redData$feed_group + redData$genetic_group + (1 | redData$recoded_id)
##
## REML criterion at convergence: -650
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.5593 -0.6841 0.0276 0.6922 3.5944
##
## Random effects:
## Groups Name Variance Std.Dev.
## redData$recoded_id (Intercept) 6.229e-18 2.496e-09
## Residual 2.867e-02 1.693e-01
## Number of obs: 1019, groups: redData$recoded_id, 305
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) -1.553e+01 1.224e+01 1.007e+03
## as.factor(redData$age_y)0 -4.027e-02 7.165e-02 1.007e+03
## as.factor(redData$age_y)2 9.962e-02 1.530e-02 1.007e+03
## as.factor(redData$age_y)3 1.143e-01 1.837e-02 1.007e+03
## as.factor(redData$age_y)4 9.524e-02 2.225e-02 1.007e+03
## as.factor(redData$age_y)5 1.231e-01 2.997e-02 1.007e+03
## as.factor(redData$age_y)6 6.731e-02 4.322e-02 1.007e+03
## redData$sample_year 7.674e-03 6.088e-03 1.007e+03
## as.numeric(paste(redData$sample_interval)) -2.006e-05 5.256e-05 1.007e+03
## redData$feed_group2 -9.068e-03 1.192e-02 1.007e+03
## redData$feed_groupNULL -1.064e-02 1.523e-02 1.007e+03
## redData$genetic_groupS -1.437e-02 1.117e-02 1.007e+03
## t value Pr(>|t|)
## (Intercept) -1.269 0.205
## as.factor(redData$age_y)0 -0.562 0.574
## as.factor(redData$age_y)2 6.509 1.19e-10 ***
## as.factor(redData$age_y)3 6.221 7.25e-10 ***
## as.factor(redData$age_y)4 4.280 2.05e-05 ***
## as.factor(redData$age_y)5 4.107 4.33e-05 ***
## as.factor(redData$age_y)6 1.558 0.120
## redData$sample_year 1.261 0.208
## as.numeric(paste(redData$sample_interval)) -0.382 0.703
## redData$feed_group2 -0.761 0.447
## redData$feed_groupNULL -0.698 0.485
## redData$genetic_groupS -1.286 0.199
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) a.(D$_)0 a.(D$_)2 a.(D$_)3 a.(D$_)4 a.(D$_)5 a.(D$_)6 rdDt$_
## as.fc(D$_)0 0.022
## as.fc(D$_)2 0.364 0.091
## as.fc(D$_)3 0.563 0.070 0.567
## as.fc(D$_)4 0.610 0.043 0.524 0.603
## as.fc(D$_)5 0.540 0.032 0.422 0.498 0.499
## as.fc(D$_)6 0.405 0.047 0.303 0.357 0.350 0.299
## rdDt$smpl_y -1.000 -0.022 -0.365 -0.564 -0.611 -0.541 -0.405
## as.n((D$_)) 0.095 0.218 0.001 -0.020 -0.085 -0.055 0.085 -0.096
## rdDt$fd_gr2 -0.042 0.035 -0.031 -0.036 -0.057 -0.081 -0.091 0.042
## rdDt$f_NULL 0.086 -0.024 0.079 0.111 0.093 0.073 0.081 -0.087
## rdDt$gntc_S 0.072 -0.028 0.022 0.057 0.050 0.058 0.064 -0.072
## a.((D$ rdD$_2 rD$_NU
## as.fc(D$_)0
## as.fc(D$_)2
## as.fc(D$_)3
## as.fc(D$_)4
## as.fc(D$_)5
## as.fc(D$_)6
## rdDt$smpl_y
## as.n((D$_))
## rdDt$fd_gr2 0.045
## rdDt$f_NULL -0.044 0.370
## rdDt$gntc_S 0.060 -0.030 0.242
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
anova(mod1f)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value
## as.factor(redData$age_y) 1.58118 0.263529 6 1007 9.1926
## redData$sample_year 0.04555 0.045550 1 1007 1.5889
## as.numeric(paste(redData$sample_interval)) 0.00418 0.004177 1 1007 0.1457
## redData$feed_group 0.02237 0.011183 2 1007 0.3901
## redData$genetic_group 0.04744 0.047438 1 1007 1.6547
## Pr(>F)
## as.factor(redData$age_y) 8.079e-10 ***
## redData$sample_year 0.2078
## as.numeric(paste(redData$sample_interval)) 0.7027
## redData$feed_group 0.6771
## redData$genetic_group 0.1986
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#Age in years as factor with reference year being 3 (Age at t-1)
contrasts(redData$R_age_y) <- contr.treatment(levels(redData$R_age_y),
base=which(levels(redData$R_age_y) == '3'))
mod1f <- lmer(as.numeric(paste(redData$diff_rltl_res)) ~
as.factor(redData$age_y) +
redData$sample_year +
as.numeric(paste(redData$sample_interval)) +
redData$feed_group +
redData$genetic_group +
(1|redData$recoded_id),
na.action=na.exclude)
## boundary (singular) fit: see ?isSingular
summary(mod1f)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: as.numeric(paste(redData$diff_rltl_res)) ~ as.factor(redData$age_y) +
## redData$sample_year + as.numeric(paste(redData$sample_interval)) +
## redData$feed_group + redData$genetic_group + (1 | redData$recoded_id)
##
## REML criterion at convergence: -650
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.5593 -0.6841 0.0276 0.6922 3.5944
##
## Random effects:
## Groups Name Variance Std.Dev.
## redData$recoded_id (Intercept) 6.229e-18 2.496e-09
## Residual 2.867e-02 1.693e-01
## Number of obs: 1019, groups: redData$recoded_id, 305
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) -1.553e+01 1.224e+01 1.007e+03
## as.factor(redData$age_y)0 -4.027e-02 7.165e-02 1.007e+03
## as.factor(redData$age_y)2 9.962e-02 1.530e-02 1.007e+03
## as.factor(redData$age_y)3 1.143e-01 1.837e-02 1.007e+03
## as.factor(redData$age_y)4 9.524e-02 2.225e-02 1.007e+03
## as.factor(redData$age_y)5 1.231e-01 2.997e-02 1.007e+03
## as.factor(redData$age_y)6 6.731e-02 4.322e-02 1.007e+03
## redData$sample_year 7.674e-03 6.088e-03 1.007e+03
## as.numeric(paste(redData$sample_interval)) -2.006e-05 5.256e-05 1.007e+03
## redData$feed_group2 -9.068e-03 1.192e-02 1.007e+03
## redData$feed_groupNULL -1.064e-02 1.523e-02 1.007e+03
## redData$genetic_groupS -1.437e-02 1.117e-02 1.007e+03
## t value Pr(>|t|)
## (Intercept) -1.269 0.205
## as.factor(redData$age_y)0 -0.562 0.574
## as.factor(redData$age_y)2 6.509 1.19e-10 ***
## as.factor(redData$age_y)3 6.221 7.25e-10 ***
## as.factor(redData$age_y)4 4.280 2.05e-05 ***
## as.factor(redData$age_y)5 4.107 4.33e-05 ***
## as.factor(redData$age_y)6 1.558 0.120
## redData$sample_year 1.261 0.208
## as.numeric(paste(redData$sample_interval)) -0.382 0.703
## redData$feed_group2 -0.761 0.447
## redData$feed_groupNULL -0.698 0.485
## redData$genetic_groupS -1.286 0.199
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) a.(D$_)0 a.(D$_)2 a.(D$_)3 a.(D$_)4 a.(D$_)5 a.(D$_)6 rdDt$_
## as.fc(D$_)0 0.022
## as.fc(D$_)2 0.364 0.091
## as.fc(D$_)3 0.563 0.070 0.567
## as.fc(D$_)4 0.610 0.043 0.524 0.603
## as.fc(D$_)5 0.540 0.032 0.422 0.498 0.499
## as.fc(D$_)6 0.405 0.047 0.303 0.357 0.350 0.299
## rdDt$smpl_y -1.000 -0.022 -0.365 -0.564 -0.611 -0.541 -0.405
## as.n((D$_)) 0.095 0.218 0.001 -0.020 -0.085 -0.055 0.085 -0.096
## rdDt$fd_gr2 -0.042 0.035 -0.031 -0.036 -0.057 -0.081 -0.091 0.042
## rdDt$f_NULL 0.086 -0.024 0.079 0.111 0.093 0.073 0.081 -0.087
## rdDt$gntc_S 0.072 -0.028 0.022 0.057 0.050 0.058 0.064 -0.072
## a.((D$ rdD$_2 rD$_NU
## as.fc(D$_)0
## as.fc(D$_)2
## as.fc(D$_)3
## as.fc(D$_)4
## as.fc(D$_)5
## as.fc(D$_)6
## rdDt$smpl_y
## as.n((D$_))
## rdDt$fd_gr2 0.045
## rdDt$f_NULL -0.044 0.370
## rdDt$gntc_S 0.060 -0.030 0.242
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
anova(mod1f)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value
## as.factor(redData$age_y) 1.58118 0.263529 6 1007 9.1926
## redData$sample_year 0.04555 0.045550 1 1007 1.5889
## as.numeric(paste(redData$sample_interval)) 0.00418 0.004177 1 1007 0.1457
## redData$feed_group 0.02237 0.011183 2 1007 0.3901
## redData$genetic_group 0.04744 0.047438 1 1007 1.6547
## Pr(>F)
## as.factor(redData$age_y) 8.079e-10 ***
## redData$sample_year 0.2078
## as.numeric(paste(redData$sample_interval)) 0.7027
## redData$feed_group 0.6771
## redData$genetic_group 0.1986
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#Age in years as factor with reference year being 4 (Age at t-1)
contrasts(redData$R_age_y) <- contr.treatment(levels(redData$R_age_y),
base=which(levels(redData$R_age_y) == '4'))
mod1f <- lmer(as.numeric(paste(redData$diff_rltl_res)) ~
as.factor(redData$age_y) +
redData$sample_year +
as.numeric(paste(redData$sample_interval)) +
redData$feed_group +
redData$genetic_group +
(1|redData$recoded_id), na.action=na.exclude)
## boundary (singular) fit: see ?isSingular
summary(mod1f)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: as.numeric(paste(redData$diff_rltl_res)) ~ as.factor(redData$age_y) +
## redData$sample_year + as.numeric(paste(redData$sample_interval)) +
## redData$feed_group + redData$genetic_group + (1 | redData$recoded_id)
##
## REML criterion at convergence: -650
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.5593 -0.6841 0.0276 0.6922 3.5944
##
## Random effects:
## Groups Name Variance Std.Dev.
## redData$recoded_id (Intercept) 6.229e-18 2.496e-09
## Residual 2.867e-02 1.693e-01
## Number of obs: 1019, groups: redData$recoded_id, 305
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) -1.553e+01 1.224e+01 1.007e+03
## as.factor(redData$age_y)0 -4.027e-02 7.165e-02 1.007e+03
## as.factor(redData$age_y)2 9.962e-02 1.530e-02 1.007e+03
## as.factor(redData$age_y)3 1.143e-01 1.837e-02 1.007e+03
## as.factor(redData$age_y)4 9.524e-02 2.225e-02 1.007e+03
## as.factor(redData$age_y)5 1.231e-01 2.997e-02 1.007e+03
## as.factor(redData$age_y)6 6.731e-02 4.322e-02 1.007e+03
## redData$sample_year 7.674e-03 6.088e-03 1.007e+03
## as.numeric(paste(redData$sample_interval)) -2.006e-05 5.256e-05 1.007e+03
## redData$feed_group2 -9.068e-03 1.192e-02 1.007e+03
## redData$feed_groupNULL -1.064e-02 1.523e-02 1.007e+03
## redData$genetic_groupS -1.437e-02 1.117e-02 1.007e+03
## t value Pr(>|t|)
## (Intercept) -1.269 0.205
## as.factor(redData$age_y)0 -0.562 0.574
## as.factor(redData$age_y)2 6.509 1.19e-10 ***
## as.factor(redData$age_y)3 6.221 7.25e-10 ***
## as.factor(redData$age_y)4 4.280 2.05e-05 ***
## as.factor(redData$age_y)5 4.107 4.33e-05 ***
## as.factor(redData$age_y)6 1.558 0.120
## redData$sample_year 1.261 0.208
## as.numeric(paste(redData$sample_interval)) -0.382 0.703
## redData$feed_group2 -0.761 0.447
## redData$feed_groupNULL -0.698 0.485
## redData$genetic_groupS -1.286 0.199
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) a.(D$_)0 a.(D$_)2 a.(D$_)3 a.(D$_)4 a.(D$_)5 a.(D$_)6 rdDt$_
## as.fc(D$_)0 0.022
## as.fc(D$_)2 0.364 0.091
## as.fc(D$_)3 0.563 0.070 0.567
## as.fc(D$_)4 0.610 0.043 0.524 0.603
## as.fc(D$_)5 0.540 0.032 0.422 0.498 0.499
## as.fc(D$_)6 0.405 0.047 0.303 0.357 0.350 0.299
## rdDt$smpl_y -1.000 -0.022 -0.365 -0.564 -0.611 -0.541 -0.405
## as.n((D$_)) 0.095 0.218 0.001 -0.020 -0.085 -0.055 0.085 -0.096
## rdDt$fd_gr2 -0.042 0.035 -0.031 -0.036 -0.057 -0.081 -0.091 0.042
## rdDt$f_NULL 0.086 -0.024 0.079 0.111 0.093 0.073 0.081 -0.087
## rdDt$gntc_S 0.072 -0.028 0.022 0.057 0.050 0.058 0.064 -0.072
## a.((D$ rdD$_2 rD$_NU
## as.fc(D$_)0
## as.fc(D$_)2
## as.fc(D$_)3
## as.fc(D$_)4
## as.fc(D$_)5
## as.fc(D$_)6
## rdDt$smpl_y
## as.n((D$_))
## rdDt$fd_gr2 0.045
## rdDt$f_NULL -0.044 0.370
## rdDt$gntc_S 0.060 -0.030 0.242
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
anova(mod1f)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value
## as.factor(redData$age_y) 1.58118 0.263529 6 1007 9.1926
## redData$sample_year 0.04555 0.045550 1 1007 1.5889
## as.numeric(paste(redData$sample_interval)) 0.00418 0.004177 1 1007 0.1457
## redData$feed_group 0.02237 0.011183 2 1007 0.3901
## redData$genetic_group 0.04744 0.047438 1 1007 1.6547
## Pr(>F)
## as.factor(redData$age_y) 8.079e-10 ***
## redData$sample_year 0.2078
## as.numeric(paste(redData$sample_interval)) 0.7027
## redData$feed_group 0.6771
## redData$genetic_group 0.1986
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#Age in years as factor with reference year being 5 (Age at t-1)
contrasts(redData$R_age_y) <- contr.treatment(levels(redData$R_age_y),
base=which(levels(redData$R_age_y) == '5'))
mod1f <- lmer(as.numeric(paste(redData$diff_rltl_res)) ~
as.factor(redData$age_y) +
redData$sample_year +
as.numeric(paste(redData$sample_interval)) +
redData$feed_group +
redData$genetic_group +
(1|redData$recoded_id), na.action=na.exclude)
## boundary (singular) fit: see ?isSingular
summary(mod1f)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: as.numeric(paste(redData$diff_rltl_res)) ~ as.factor(redData$age_y) +
## redData$sample_year + as.numeric(paste(redData$sample_interval)) +
## redData$feed_group + redData$genetic_group + (1 | redData$recoded_id)
##
## REML criterion at convergence: -650
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.5593 -0.6841 0.0276 0.6922 3.5944
##
## Random effects:
## Groups Name Variance Std.Dev.
## redData$recoded_id (Intercept) 6.229e-18 2.496e-09
## Residual 2.867e-02 1.693e-01
## Number of obs: 1019, groups: redData$recoded_id, 305
##
## Fixed effects:
## Estimate Std. Error df
## (Intercept) -1.553e+01 1.224e+01 1.007e+03
## as.factor(redData$age_y)0 -4.027e-02 7.165e-02 1.007e+03
## as.factor(redData$age_y)2 9.962e-02 1.530e-02 1.007e+03
## as.factor(redData$age_y)3 1.143e-01 1.837e-02 1.007e+03
## as.factor(redData$age_y)4 9.524e-02 2.225e-02 1.007e+03
## as.factor(redData$age_y)5 1.231e-01 2.997e-02 1.007e+03
## as.factor(redData$age_y)6 6.731e-02 4.322e-02 1.007e+03
## redData$sample_year 7.674e-03 6.088e-03 1.007e+03
## as.numeric(paste(redData$sample_interval)) -2.006e-05 5.256e-05 1.007e+03
## redData$feed_group2 -9.068e-03 1.192e-02 1.007e+03
## redData$feed_groupNULL -1.064e-02 1.523e-02 1.007e+03
## redData$genetic_groupS -1.437e-02 1.117e-02 1.007e+03
## t value Pr(>|t|)
## (Intercept) -1.269 0.205
## as.factor(redData$age_y)0 -0.562 0.574
## as.factor(redData$age_y)2 6.509 1.19e-10 ***
## as.factor(redData$age_y)3 6.221 7.25e-10 ***
## as.factor(redData$age_y)4 4.280 2.05e-05 ***
## as.factor(redData$age_y)5 4.107 4.33e-05 ***
## as.factor(redData$age_y)6 1.558 0.120
## redData$sample_year 1.261 0.208
## as.numeric(paste(redData$sample_interval)) -0.382 0.703
## redData$feed_group2 -0.761 0.447
## redData$feed_groupNULL -0.698 0.485
## redData$genetic_groupS -1.286 0.199
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) a.(D$_)0 a.(D$_)2 a.(D$_)3 a.(D$_)4 a.(D$_)5 a.(D$_)6 rdDt$_
## as.fc(D$_)0 0.022
## as.fc(D$_)2 0.364 0.091
## as.fc(D$_)3 0.563 0.070 0.567
## as.fc(D$_)4 0.610 0.043 0.524 0.603
## as.fc(D$_)5 0.540 0.032 0.422 0.498 0.499
## as.fc(D$_)6 0.405 0.047 0.303 0.357 0.350 0.299
## rdDt$smpl_y -1.000 -0.022 -0.365 -0.564 -0.611 -0.541 -0.405
## as.n((D$_)) 0.095 0.218 0.001 -0.020 -0.085 -0.055 0.085 -0.096
## rdDt$fd_gr2 -0.042 0.035 -0.031 -0.036 -0.057 -0.081 -0.091 0.042
## rdDt$f_NULL 0.086 -0.024 0.079 0.111 0.093 0.073 0.081 -0.087
## rdDt$gntc_S 0.072 -0.028 0.022 0.057 0.050 0.058 0.064 -0.072
## a.((D$ rdD$_2 rD$_NU
## as.fc(D$_)0
## as.fc(D$_)2
## as.fc(D$_)3
## as.fc(D$_)4
## as.fc(D$_)5
## as.fc(D$_)6
## rdDt$smpl_y
## as.n((D$_))
## rdDt$fd_gr2 0.045
## rdDt$f_NULL -0.044 0.370
## rdDt$gntc_S 0.060 -0.030 0.242
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
anova(mod1f)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value
## as.factor(redData$age_y) 1.58118 0.263529 6 1007 9.1926
## redData$sample_year 0.04555 0.045550 1 1007 1.5889
## as.numeric(paste(redData$sample_interval)) 0.00418 0.004177 1 1007 0.1457
## redData$feed_group 0.02237 0.011183 2 1007 0.3901
## redData$genetic_group 0.04744 0.047438 1 1007 1.6547
## Pr(>F)
## as.factor(redData$age_y) 8.079e-10 ***
## redData$sample_year 0.2078
## as.numeric(paste(redData$sample_interval)) 0.7027
## redData$feed_group 0.6771
## redData$genetic_group 0.1986
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
nrow(subset(redData, redData$age_y == 6))
## [1] 20
In a lot pf publications RLTL change is investigated by fitting a model of RLTL at time t and with RLTL at time t-1 as covariate. This is different to looking at RLTL change and fitting RLTL at the first time point as covariate which is problematic due to statistical problems that happen due to regression to the mean.
mod1 <- lmer(as.numeric(paste(redData$residual_rltl_t)) ~
as.numeric(paste(redData$residual_rltl_tminus1)) +
as.factor(redData$age_y) +
redData$sample_year +
as.numeric(paste(redData$sample_interval)) +
redData$feed_group +
redData$genetic_group +
(1|redData$recoded_id), na.action=na.exclude)
summary(mod1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## as.numeric(paste(redData$residual_rltl_t)) ~ as.numeric(paste(redData$residual_rltl_tminus1)) +
## as.factor(redData$age_y) + redData$sample_year + as.numeric(paste(redData$sample_interval)) +
## redData$feed_group + redData$genetic_group + (1 | redData$recoded_id)
##
## REML criterion at convergence: -1051.7
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.5536 -0.6651 -0.0687 0.5785 3.1145
##
## Random effects:
## Groups Name Variance Std.Dev.
## redData$recoded_id (Intercept) 0.005017 0.07083
## Residual 0.015504 0.12452
## Number of obs: 1019, groups: redData$recoded_id, 305
##
## Fixed effects:
## Estimate Std. Error
## (Intercept) 7.046e+00 1.204e+01
## as.numeric(paste(redData$residual_rltl_tminus1)) 1.817e-01 3.009e-02
## as.factor(redData$age_y)0 6.777e-02 5.883e-02
## as.factor(redData$age_y)2 2.279e-02 1.240e-02
## as.factor(redData$age_y)3 3.418e-02 1.598e-02
## as.factor(redData$age_y)4 2.663e-02 2.029e-02
## as.factor(redData$age_y)5 6.584e-02 2.740e-02
## as.factor(redData$age_y)6 3.883e-02 3.753e-02
## redData$sample_year -3.537e-03 5.988e-03
## as.numeric(paste(redData$sample_interval)) 3.493e-05 4.190e-05
## redData$feed_group2 6.674e-03 1.302e-02
## redData$feed_groupNULL 5.958e-03 1.595e-02
## redData$genetic_groupS 6.433e-03 1.209e-02
## df t value Pr(>|t|)
## (Intercept) 2.419e+02 0.585 0.5590
## as.numeric(paste(redData$residual_rltl_tminus1)) 8.971e+02 6.038 2.28e-09
## as.factor(redData$age_y)0 9.846e+02 1.152 0.2496
## as.factor(redData$age_y)2 9.767e+02 1.838 0.0664
## as.factor(redData$age_y)3 7.254e+02 2.139 0.0328
## as.factor(redData$age_y)4 4.494e+02 1.313 0.1899
## as.factor(redData$age_y)5 4.639e+02 2.403 0.0166
## as.factor(redData$age_y)6 8.328e+02 1.035 0.3011
## redData$sample_year 2.419e+02 -0.591 0.5553
## as.numeric(paste(redData$sample_interval)) 8.644e+02 0.834 0.4047
## redData$feed_group2 1.224e+02 0.513 0.6090
## redData$feed_groupNULL 1.539e+02 0.374 0.7092
## redData$genetic_groupS 1.322e+02 0.532 0.5956
##
## (Intercept)
## as.numeric(paste(redData$residual_rltl_tminus1)) ***
## as.factor(redData$age_y)0
## as.factor(redData$age_y)2 .
## as.factor(redData$age_y)3 *
## as.factor(redData$age_y)4
## as.factor(redData$age_y)5 *
## as.factor(redData$age_y)6
## redData$sample_year
## as.numeric(paste(redData$sample_interval))
## redData$feed_group2
## redData$feed_groupNULL
## redData$genetic_groupS
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation matrix not shown by default, as p = 13 > 12.
## Use print(x, correlation=TRUE) or
## vcov(x) if you need it
anova(mod1)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF
## as.numeric(paste(redData$residual_rltl_tminus1)) 0.56527 0.56527 1 897.13
## as.factor(redData$age_y) 0.13385 0.02231 6 776.02
## redData$sample_year 0.00541 0.00541 1 241.94
## as.numeric(paste(redData$sample_interval)) 0.01077 0.01077 1 864.36
## redData$feed_group 0.00465 0.00232 2 138.88
## redData$genetic_group 0.00439 0.00439 1 132.23
## F value Pr(>F)
## as.numeric(paste(redData$residual_rltl_tminus1)) 36.4591 2.281e-09 ***
## as.factor(redData$age_y) 1.4388 0.1969
## redData$sample_year 0.3488 0.5553
## as.numeric(paste(redData$sample_interval)) 0.6949 0.4047
## redData$feed_group 0.1499 0.8610
## redData$genetic_group 0.2830 0.5956
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Reduce model by removinf non-significant effects.
mod1 <- lmer(as.numeric(paste(redData$residual_rltl_t)) ~
as.numeric(paste(redData$residual_rltl_tminus1)) +
(1|redData$recoded_id), na.action=na.exclude)
summary(mod1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula:
## as.numeric(paste(redData$residual_rltl_t)) ~ as.numeric(paste(redData$residual_rltl_tminus1)) +
## (1 | redData$recoded_id)
##
## REML criterion at convergence: -1123.1
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.40851 -0.66068 -0.07773 0.53433 2.99380
##
## Random effects:
## Groups Name Variance Std.Dev.
## redData$recoded_id (Intercept) 0.006051 0.07779
## Residual 0.015001 0.12248
## Number of obs: 1019, groups: redData$recoded_id, 305
##
## Fixed effects:
## Estimate Std. Error
## (Intercept) -0.02931 0.00600
## as.numeric(paste(redData$residual_rltl_tminus1)) 0.13180 0.02788
## df t value Pr(>|t|)
## (Intercept) 168.14433 -4.886 2.39e-06
## as.numeric(paste(redData$residual_rltl_tminus1)) 1011.64068 4.727 2.60e-06
##
## (Intercept) ***
## as.numeric(paste(redData$residual_rltl_tminus1)) ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr)
## a.((D$__1)) -0.035
anova(mod1)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF
## as.numeric(paste(redData$residual_rltl_tminus1)) 0.33522 0.33522 1 1011.6
## F value Pr(>F)
## as.numeric(paste(redData$residual_rltl_tminus1)) 22.347 2.598e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# statistical tests for normal distribution of RTL measurements
shapiro.test(as.numeric(paste(uDeadData$herd_life)))
##
## Shapiro-Wilk normality test
##
## data: as.numeric(paste(uDeadData$herd_life))
## W = 0.98408, p-value = 0.008487
ks.test(as.numeric(paste(uDeadData$herd_life)), pnorm)
## Warning in ks.test(as.numeric(paste(uDeadData$herd_life)), pnorm): ties should
## not be present for the Kolmogorov-Smirnov test
##
## One-sample Kolmogorov-Smirnov test
##
## data: as.numeric(paste(uDeadData$herd_life))
## D = 1, p-value < 2.2e-16
## alternative hypothesis: two-sided
qqnorm(as.numeric(paste(uDeadData$herd_life)))
Investigate the effect of average telomere length over life on productive life span:
produc <-as.numeric(paste(uDeadData$amp_305_lactation))
## Warning: NAs introduced by coercion
mod2 <- glm(as.numeric(paste(uDeadData$herd_life)) ~
uDeadData$average_resid +
produc)
summary(mod2)
##
## Call:
## glm(formula = as.numeric(paste(uDeadData$herd_life)) ~ uDeadData$average_resid +
## produc)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -794.08 -361.00 -35.95 311.94 1283.75
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1205.21924 76.16160 15.825 < 2e-16 ***
## uDeadData$average_resid -135.44248 299.38143 -0.452 0.651
## produc 0.07095 0.01075 6.597 4.18e-10 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 215047.8)
##
## Null deviance: 49655637 on 189 degrees of freedom
## Residual deviance: 40213930 on 187 degrees of freedom
## (51 observations deleted due to missingness)
## AIC: 2877.1
##
## Number of Fisher Scoring iterations: 2
Average telomere length over life is not significantly correlated with productive lifespan. But milk productivity correlates with productive lifespan (animals that live for longer have more opportunity to produce more. But it is an average milk productivity measurement which could also mean that animals that are more productive are kept for longer in the herd)
Average telomere change over life is associated with productive lifespan.
Repeat analysis for animals with more than two samples: uDeadDataMore2
redDeadMore2 <- subset(u_more_2, u_more_2$herd_life != "NULL")
uDeadDataMore2 <- redDeadMore2[!duplicated(redDeadMore2$recoded_id),]
product <- as.numeric(paste(uDeadDataMore2$amp_305_lactation))
## Warning: NAs introduced by coercion
mod2 <- glm(as.numeric(paste(uDeadDataMore2$herd_life)) ~
uDeadDataMore2$average_resid +
product)
summary(mod2)
##
## Call:
## glm(formula = as.numeric(paste(uDeadDataMore2$herd_life)) ~ uDeadDataMore2$average_resid +
## product)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -774.53 -377.92 -42.55 335.50 1238.72
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.271e+03 8.264e+01 15.382 < 2e-16 ***
## uDeadDataMore2$average_resid 3.831e+00 3.035e+02 0.013 0.99
## product 6.308e-02 1.133e-02 5.566 9.25e-08 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 215215.5)
##
## Null deviance: 45657680 on 183 degrees of freedom
## Residual deviance: 38954006 on 181 degrees of freedom
## (29 observations deleted due to missingness)
## AIC: 2786.6
##
## Number of Fisher Scoring iterations: 2
mod3a <- glm(as.numeric(paste(uDeadDataMore2$herd_life)) ~
as.numeric(paste(uDeadDataMore2$rltl_change)) +
product)
summary(mod3a)
##
## Call:
## glm(formula = as.numeric(paste(uDeadDataMore2$herd_life)) ~ as.numeric(paste(uDeadDataMore2$rltl_change)) +
## product)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -787.33 -364.01 -52.38 318.81 1224.01
##
## Coefficients:
## Estimate Std. Error t value
## (Intercept) 1.294e+03 8.446e+01 15.316
## as.numeric(paste(uDeadDataMore2$rltl_change)) 5.775e+02 6.028e+02 0.958
## product 6.238e-02 1.130e-02 5.521
## Pr(>|t|)
## (Intercept) < 2e-16 ***
## as.numeric(paste(uDeadDataMore2$rltl_change)) 0.339
## product 1.16e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 214130)
##
## Null deviance: 45657680 on 183 degrees of freedom
## Residual deviance: 38757530 on 181 degrees of freedom
## (29 observations deleted due to missingness)
## AIC: 2785.6
##
## Number of Fisher Scoring iterations: 2
AIC(mod3a)
## [1] 2785.623
mod3b <- glm(as.numeric(paste(uDeadDataMore2$herd_life)) ~
as.numeric(paste(uDeadDataMore2$abs_rltl_change)) +
product)
summary(mod3b)
##
## Call:
## glm(formula = as.numeric(paste(uDeadDataMore2$herd_life)) ~ as.numeric(paste(uDeadDataMore2$abs_rltl_change)) +
## product)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -810.56 -386.38 -32.43 326.01 1251.06
##
## Coefficients:
## Estimate Std. Error t value
## (Intercept) 1344.28343 110.91823 12.120
## as.numeric(paste(uDeadDataMore2$abs_rltl_change)) -541.34365 558.66779 -0.969
## product 0.06374 0.01129 5.643
## Pr(>|t|)
## (Intercept) < 2e-16 ***
## as.numeric(paste(uDeadDataMore2$abs_rltl_change)) 0.334
## product 6.34e-08 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 214105)
##
## Null deviance: 45657680 on 183 degrees of freedom
## Residual deviance: 38753008 on 181 degrees of freedom
## (29 observations deleted due to missingness)
## AIC: 2785.6
##
## Number of Fisher Scoring iterations: 2
AIC(mod3b)
## [1] 2785.601
AIC(mod3b)-AIC(mod3a)
## [1] -0.02147028
#All together
mod3c <- glm(as.numeric(paste(uDeadDataMore2$herd_life)) ~
as.numeric(paste(uDeadDataMore2$rltl_change)) +
as.numeric(paste(uDeadDataMore2$abs_rltl_change)) +
uDeadDataMore2$average_resid +product)
summary(mod3c)
##
## Call:
## glm(formula = as.numeric(paste(uDeadDataMore2$herd_life)) ~ as.numeric(paste(uDeadDataMore2$rltl_change)) +
## as.numeric(paste(uDeadDataMore2$abs_rltl_change)) + uDeadDataMore2$average_resid +
## product)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -813.50 -364.81 -61.04 328.87 1236.41
##
## Coefficients:
## Estimate Std. Error t value
## (Intercept) 1345.44375 114.08909 11.793
## as.numeric(paste(uDeadDataMore2$rltl_change)) 443.74881 644.06446 0.689
## as.numeric(paste(uDeadDataMore2$abs_rltl_change)) -421.00056 595.89616 -0.706
## uDeadDataMore2$average_resid 1.53645 311.59944 0.005
## product 0.06304 0.01140 5.532
## Pr(>|t|)
## (Intercept) < 2e-16 ***
## as.numeric(paste(uDeadDataMore2$rltl_change)) 0.492
## as.numeric(paste(uDeadDataMore2$abs_rltl_change)) 0.481
## uDeadDataMore2$average_resid 0.996
## product 1.11e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 215903.2)
##
## Null deviance: 45657680 on 183 degrees of freedom
## Residual deviance: 38646678 on 179 degrees of freedom
## (29 observations deleted due to missingness)
## AIC: 2789.1
##
## Number of Fisher Scoring iterations: 2
mod3d <- glm(as.numeric(paste(uDeadDataMore2$herd_life)) ~
as.numeric(paste(uDeadDataMore2$rltl_change)) +
as.numeric(paste(uDeadDataMore2$abs_rltl_change)) +
product)
summary(mod3d)
##
## Call:
## glm(formula = as.numeric(paste(uDeadDataMore2$herd_life)) ~ as.numeric(paste(uDeadDataMore2$rltl_change)) +
## as.numeric(paste(uDeadDataMore2$abs_rltl_change)) + product)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -813.44 -364.72 -60.94 328.88 1236.64
##
## Coefficients:
## Estimate Std. Error t value
## (Intercept) 1345.32218 111.08303 12.111
## as.numeric(paste(uDeadDataMore2$rltl_change)) 444.33049 631.40750 0.704
## as.numeric(paste(uDeadDataMore2$abs_rltl_change)) -420.49044 585.21439 -0.719
## product 0.06305 0.01135 5.554
## Pr(>|t|)
## (Intercept) < 2e-16 ***
## as.numeric(paste(uDeadDataMore2$rltl_change)) 0.483
## as.numeric(paste(uDeadDataMore2$abs_rltl_change)) 0.473
## product 9.92e-08 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 214703.8)
##
## Null deviance: 45657680 on 183 degrees of freedom
## Residual deviance: 38646683 on 180 degrees of freedom
## (29 observations deleted due to missingness)
## AIC: 2787.1
##
## Number of Fisher Scoring iterations: 2
coxFit <- coxph(Surv(coxData$TimeMeasure, coxData$Event == 1) ~
coxData$average_resid)
summary(coxFit)
## Call:
## coxph(formula = Surv(coxData$TimeMeasure, coxData$Event == 1) ~
## coxData$average_resid)
##
## n= 305, number of events= 241
##
## coef exp(coef) se(coef) z Pr(>|z|)
## coxData$average_resid 0.3407 1.4059 0.5905 0.577 0.564
##
## exp(coef) exp(-coef) lower .95 upper .95
## coxData$average_resid 1.406 0.7113 0.4419 4.473
##
## Concordance= 0.509 (se = 0.021 )
## Likelihood ratio test= 0.33 on 1 df, p=0.6
## Wald test = 0.33 on 1 df, p=0.6
## Score (logrank) test = 0.33 on 1 df, p=0.6
summary(coxFit)$logtest["pvalue"]
## pvalue
## 0.5641153
### discrete scale
coxFit <- coxph(Surv(coxData$TimeMeasure, coxData$Event == 1) ~
coxData$average_resid_3G)
summary(coxFit)
## Call:
## coxph(formula = Surv(coxData$TimeMeasure, coxData$Event == 1) ~
## coxData$average_resid_3G)
##
## n= 305, number of events= 241
##
## coef exp(coef) se(coef) z Pr(>|z|)
## coxData$average_resid_3G 0.01410 1.01420 0.07886 0.179 0.858
##
## exp(coef) exp(-coef) lower .95 upper .95
## coxData$average_resid_3G 1.014 0.986 0.869 1.184
##
## Concordance= 0.501 (se = 0.02 )
## Likelihood ratio test= 0.03 on 1 df, p=0.9
## Wald test = 0.03 on 1 df, p=0.9
## Score (logrank) test = 0.03 on 1 df, p=0.9
They show the same as Cox proportional hazard models.
dData <- subset(data, data$herd_life != "NULL")
cor.test(as.numeric(paste(dData$herd_life)), dData$abs_rltl_change)
##
## Pearson's product-moment correlation
##
## data: as.numeric(paste(dData$herd_life)) and dData$abs_rltl_change
## t = -5.5853, df = 1020, p-value = 2.991e-08
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.2311491 -0.1121316
## sample estimates:
## cor
## -0.172269
cor.test(as.numeric(paste(dData$herd_life)), dData$rltl_change)
##
## Pearson's product-moment correlation
##
## data: as.numeric(paste(dData$herd_life)) and dData$rltl_change
## t = 8.4519, df = 1020, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## 0.1976120 0.3122569
## sample estimates:
## cor
## 0.2558338
cor.test(as.numeric(paste(dData$herd_life)), dData$average_resid)
##
## Pearson's product-moment correlation
##
## data: as.numeric(paste(dData$herd_life)) and dData$average_resid
## t = -0.19531, df = 1020, p-value = 0.8452
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.06741195 0.05522731
## sample estimates:
## cor
## -0.006115315
tert2 <- ggplot(coxData, aes(
x = as.factor(coxData$abs_rltl_change_3G),
y = abs_rltl_change,
colour = as.factor(coxData$abs_rltl_change_3G)
)) +
geom_boxplot() +
xlab("Mean absolute RLTL change tertile") +
ylab("Mean absolute RLTL change") +
theme_light(20) +
geom_jitter() +
scale_color_manual(values = mycoloursP[35:40]) +
theme(legend.position = "none")
tert3 <- ggplot(coxData, aes(
x = as.factor(coxData$rltl_change_3G),
y = rltl_change,
colour = as.factor(coxData$rltl_change_3G)
)) +
geom_boxplot() +
xlab("Mean RLTL change tertile") +
ylab("Mean RLTL change") +
theme_light(20) +
geom_jitter() +
scale_color_manual(values = mycoloursP[10:40]) +
theme(legend.position = "none")
tert4 <- ggplot(coxData, aes(
x = as.factor(coxData$average_resid_3G),
y = average_resid,
colour = as.factor(coxData$average_resid_3G)
)) +
geom_boxplot() +
xlab("Mean RLTL tertile") +
ylab("Mean RLTL") +
theme_light(20) +
geom_jitter() +
scale_color_manual(values = mycoloursP[5:40]) +
theme(legend.position = "none")
grid.arrange(tert4, tert2, tert3, ncol = 3)
## Warning: Use of `coxData$average_resid_3G` is discouraged. Use
## `average_resid_3G` instead.
## Warning: Use of `coxData$average_resid_3G` is discouraged. Use
## `average_resid_3G` instead.
## Warning: Use of `coxData$average_resid_3G` is discouraged. Use
## `average_resid_3G` instead.
## Warning: Use of `coxData$average_resid_3G` is discouraged. Use
## `average_resid_3G` instead.
## Warning: Use of `coxData$abs_rltl_change_3G` is discouraged. Use
## `abs_rltl_change_3G` instead.
## Warning: Use of `coxData$abs_rltl_change_3G` is discouraged. Use
## `abs_rltl_change_3G` instead.
## Warning: Use of `coxData$abs_rltl_change_3G` is discouraged. Use
## `abs_rltl_change_3G` instead.
## Warning: Use of `coxData$abs_rltl_change_3G` is discouraged. Use
## `abs_rltl_change_3G` instead.
## Warning: Use of `coxData$rltl_change_3G` is discouraged. Use `rltl_change_3G`
## instead.
## Warning: Use of `coxData$rltl_change_3G` is discouraged. Use `rltl_change_3G`
## instead.
## Warning: Use of `coxData$rltl_change_3G` is discouraged. Use `rltl_change_3G`
## instead.
## Warning: Use of `coxData$rltl_change_3G` is discouraged. Use `rltl_change_3G`
## instead.
surv_plotlist<-list()
surv_plotlist[[1]] <- meanRLTL
surv_plotlist[[2]] <- mean_abs_rltl_change
surv_plotlist[[3]] <- mean_rltl_change
print(arrange_ggsurvplots(surv_plotlist, print = TRUE, ncol = 3, nrow = 1))
## [[1]]
## NULL
coxFit <- coxph(Surv(coxData$TimeMeasure, coxData$Event == 1)~coxData$av_rltl_1_res)
summary(coxFit)
## Call:
## coxph(formula = Surv(coxData$TimeMeasure, coxData$Event == 1) ~
## coxData$av_rltl_1_res)
##
## n= 284, number of events= 221
## (21 observations deleted due to missingness)
##
## coef exp(coef) se(coef) z Pr(>|z|)
## coxData$av_rltl_1_res -0.9961 0.3693 0.4774 -2.087 0.0369 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## exp(coef) exp(-coef) lower .95 upper .95
## coxData$av_rltl_1_res 0.3693 2.708 0.1449 0.9414
##
## Concordance= 0.544 (se = 0.021 )
## Likelihood ratio test= 4.38 on 1 df, p=0.04
## Wald test = 4.35 on 1 df, p=0.04
## Score (logrank) test = 4.36 on 1 df, p=0.04
coxFit <- coxph(Surv(coxData$TimeMeasure, coxData$Event == 1) ~
coxData$rltl_change +
coxData$average_resid +
coxData$abs_rltl_change)
summary(coxFit)
coxFit <- coxph(Surv(coxDataR$TimeMeasure, coxDataR$Event == 1) ~
coxDataR$average_resid +
as.numeric(paste(coxDataR$amp_305_lactation)))
summary(coxFit)
## Call:
## coxph(formula = Surv(coxDataR$TimeMeasure, coxDataR$Event ==
## 1) ~ coxDataR$average_resid + as.numeric(paste(coxDataR$amp_305_lactation)))
##
## n= 253, number of events= 190
##
## coef exp(coef) se(coef)
## coxDataR$average_resid 2.315e-01 1.260e+00 6.708e-01
## as.numeric(paste(coxDataR$amp_305_lactation)) -9.933e-05 9.999e-01 2.822e-05
## z Pr(>|z|)
## coxDataR$average_resid 0.345 0.730011
## as.numeric(paste(coxDataR$amp_305_lactation)) -3.520 0.000432 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## exp(coef) exp(-coef) lower .95
## coxDataR$average_resid 1.2605 0.7934 0.3385
## as.numeric(paste(coxDataR$amp_305_lactation)) 0.9999 1.0001 0.9998
## upper .95
## coxDataR$average_resid 4.693
## as.numeric(paste(coxDataR$amp_305_lactation)) 1.000
##
## Concordance= 0.598 (se = 0.023 )
## Likelihood ratio test= 11.93 on 2 df, p=0.003
## Wald test = 12.43 on 2 df, p=0.002
## Score (logrank) test = 12.44 on 2 df, p=0.002
coxFit <- coxph(Surv(coxDataR$TimeMeasure, coxDataR$Event == 1) ~
coxDataR$abs_rltl_change +
as.numeric(paste(coxDataR$amp_305_lactation)))
summary(coxFit)
## Call:
## coxph(formula = Surv(coxDataR$TimeMeasure, coxDataR$Event ==
## 1) ~ coxDataR$abs_rltl_change + as.numeric(paste(coxDataR$amp_305_lactation)))
##
## n= 253, number of events= 190
##
## coef exp(coef) se(coef)
## coxDataR$abs_rltl_change 2.411e+00 1.115e+01 1.146e+00
## as.numeric(paste(coxDataR$amp_305_lactation)) -1.018e-04 9.999e-01 2.818e-05
## z Pr(>|z|)
## coxDataR$abs_rltl_change 2.104 0.035391 *
## as.numeric(paste(coxDataR$amp_305_lactation)) -3.611 0.000305 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## exp(coef) exp(-coef) lower .95
## coxDataR$abs_rltl_change 11.1466 0.08971 1.1793
## as.numeric(paste(coxDataR$amp_305_lactation)) 0.9999 1.00010 0.9998
## upper .95
## coxDataR$abs_rltl_change 105.4
## as.numeric(paste(coxDataR$amp_305_lactation)) 1.0
##
## Concordance= 0.598 (se = 0.023 )
## Likelihood ratio test= 15.99 on 2 df, p=3e-04
## Wald test = 17.06 on 2 df, p=2e-04
## Score (logrank) test = 17.08 on 2 df, p=2e-04
coxFit <- coxph(Surv(coxDataR$TimeMeasure, coxDataR$Event == 1) ~
coxDataR$rltl_change +
as.numeric(paste(coxDataR$amp_305_lactation)))
summary(coxFit)
## Call:
## coxph(formula = Surv(coxDataR$TimeMeasure, coxDataR$Event ==
## 1) ~ coxDataR$rltl_change + as.numeric(paste(coxDataR$amp_305_lactation)))
##
## n= 253, number of events= 190
##
## coef exp(coef) se(coef)
## coxDataR$rltl_change -5.035e+00 6.506e-03 1.315e+00
## as.numeric(paste(coxDataR$amp_305_lactation)) -9.057e-05 9.999e-01 2.819e-05
## z Pr(>|z|)
## coxDataR$rltl_change -3.829 0.000129 ***
## as.numeric(paste(coxDataR$amp_305_lactation)) -3.212 0.001317 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## exp(coef) exp(-coef) lower .95
## coxDataR$rltl_change 0.006506 153.7 0.0004944
## as.numeric(paste(coxDataR$amp_305_lactation)) 0.999909 1.0 0.9998542
## upper .95
## coxDataR$rltl_change 0.08562
## as.numeric(paste(coxDataR$amp_305_lactation)) 0.99996
##
## Concordance= 0.601 (se = 0.022 )
## Likelihood ratio test= 25.19 on 2 df, p=3e-06
## Wald test = 28.18 on 2 df, p=8e-07
## Score (logrank) test = 26.7 on 2 df, p=2e-06
coxFit <- coxph(Surv(coxDataR$TimeMeasure, coxDataR$Event == 1) ~
coxDataR$rltl_change +
coxDataR$av_rltl_1_res +
as.numeric(paste(coxDataR$amp_305_lactation)))
summary(coxFit)
## Call:
## coxph(formula = Surv(coxDataR$TimeMeasure, coxDataR$Event ==
## 1) ~ coxDataR$rltl_change + coxDataR$av_rltl_1_res + as.numeric(paste(coxDataR$amp_305_lactation)))
##
## n= 239, number of events= 177
## (14 observations deleted due to missingness)
##
## coef exp(coef) se(coef)
## coxDataR$rltl_change -5.030e+00 6.537e-03 1.379e+00
## coxDataR$av_rltl_1_res -6.552e-01 5.193e-01 5.263e-01
## as.numeric(paste(coxDataR$amp_305_lactation)) -7.896e-05 9.999e-01 2.928e-05
## z Pr(>|z|)
## coxDataR$rltl_change -3.648 0.000264 ***
## coxDataR$av_rltl_1_res -1.245 0.213134
## as.numeric(paste(coxDataR$amp_305_lactation)) -2.696 0.007008 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## exp(coef) exp(-coef) lower .95
## coxDataR$rltl_change 0.006537 152.972 0.0004382
## coxDataR$av_rltl_1_res 0.519327 1.926 0.1851255
## as.numeric(paste(coxDataR$amp_305_lactation)) 0.999921 1.000 0.9998637
## upper .95
## coxDataR$rltl_change 0.09752
## coxDataR$av_rltl_1_res 1.45685
## as.numeric(paste(coxDataR$amp_305_lactation)) 0.99998
##
## Concordance= 0.595 (se = 0.023 )
## Likelihood ratio test= 22.47 on 3 df, p=5e-05
## Wald test = 25.18 on 3 df, p=1e-05
## Score (logrank) test = 23.85 on 3 df, p=3e-05
coxFit <- coxph(Surv(coxDataR$TimeMeasure, coxDataR$Event == 1) ~
coxDataR$rltl_change +
coxDataR$average_resid +
coxDataR$abs_rltl_change +
as.numeric(paste(coxDataR$amp_305_lactation)))
summary(coxFit)
## Call:
## coxph(formula = Surv(coxDataR$TimeMeasure, coxDataR$Event ==
## 1) ~ coxDataR$rltl_change + coxDataR$average_resid + coxDataR$abs_rltl_change +
## as.numeric(paste(coxDataR$amp_305_lactation)))
##
## n= 253, number of events= 190
##
## coef exp(coef) se(coef)
## coxDataR$rltl_change -4.525e+00 1.083e-02 1.387e+00
## coxDataR$average_resid -6.968e-02 9.327e-01 6.840e-01
## coxDataR$abs_rltl_change 1.237e+00 3.447e+00 1.224e+00
## as.numeric(paste(coxDataR$amp_305_lactation)) -9.162e-05 9.999e-01 2.824e-05
## z Pr(>|z|)
## coxDataR$rltl_change -3.262 0.00111 **
## coxDataR$average_resid -0.102 0.91885
## coxDataR$abs_rltl_change 1.011 0.31198
## as.numeric(paste(coxDataR$amp_305_lactation)) -3.244 0.00118 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## exp(coef) exp(-coef) lower .95
## coxDataR$rltl_change 0.01083 92.3027 0.0007142
## coxDataR$average_resid 0.93269 1.0722 0.2440869
## coxDataR$abs_rltl_change 3.44666 0.2901 0.3130755
## as.numeric(paste(coxDataR$amp_305_lactation)) 0.99991 1.0001 0.9998530
## upper .95
## coxDataR$rltl_change 0.1643
## coxDataR$average_resid 3.5639
## coxDataR$abs_rltl_change 37.9445
## as.numeric(paste(coxDataR$amp_305_lactation)) 1.0000
##
## Concordance= 0.6 (se = 0.022 )
## Likelihood ratio test= 26.21 on 4 df, p=3e-05
## Wald test = 30.41 on 4 df, p=4e-06
## Score (logrank) test = 28.88 on 4 df, p=8e-06
summary(as.numeric(paste(red_data_l_new$diff_rltl_res)))
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## -0.72730 -0.15316 -0.03555 -0.03257 0.08741 0.48019
summary(as.numeric(paste(data$diff_rltl_res)))
## Warning in summary(as.numeric(paste(data$diff_rltl_res))): NAs introduced by
## coercion
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## -0.72730 -0.15310 -0.03538 -0.03243 0.08796 0.48019 305
WHAT IS THAT BELOW??
u_red_data_l_new <- red_data_l_new[!duplicated(red_data_l_new$recoded_id), ]
coxDataL <- data.frame(recoded_id = u_red_data_l_new$recoded_id,
dob = u_red_data_l_new$dob,
herd_life = u_red_data_l_new$herd_life,
cull_date = u_red_data_l_new$cull_date,
average_resid = u_red_data_l_new$average_resid,
rltl_change = u_red_data_l_new$rltl_change,
abs_rltl_change = u_red_data_l_new$abs_rltl_change,
amp_305_lactation = u_red_data_l_new$amp_305_lactation)
coxDataL$CutoffDate <- "01/01/2017"
coxDataL$Event <- ifelse(coxDataL$cull_date == "NULL", 0, 1)
coxDataL$TimeMeasure <- ifelse(coxDataL$Event == 0,
as.Date(coxDataL$CutoffDate, "%d/%m/%Y") -
as.Date(coxDataL$dob, "%d/%m/%Y"),
as.numeric(paste(coxDataL$herd_life)))
## Warning in ifelse(coxDataL$Event == 0, as.Date(coxDataL$CutoffDate, "%d/%m/%Y")
## - : NAs introduced by coercion
coxFit <- coxph(Surv(coxDataL$TimeMeasure, coxDataL$Event == 1) ~ coxDataL$average_resid)
summary(coxFit)
## Call:
## coxph(formula = Surv(coxDataL$TimeMeasure, coxDataL$Event ==
## 1) ~ coxDataL$average_resid)
##
## n= 304, number of events= 240
##
## coef exp(coef) se(coef) z Pr(>|z|)
## coxDataL$average_resid -0.5647 0.5686 0.5667 -0.996 0.319
##
## exp(coef) exp(-coef) lower .95 upper .95
## coxDataL$average_resid 0.5686 1.759 0.1873 1.726
##
## Concordance= 0.524 (se = 0.021 )
## Likelihood ratio test= 1 on 1 df, p=0.3
## Wald test = 0.99 on 1 df, p=0.3
## Score (logrank) test = 0.99 on 1 df, p=0.3
coxFit <- coxph(Surv(coxDataL$TimeMeasure, coxDataL$Event == 1)~coxDataL$abs_rltl_change)
summary(coxFit)
## Call:
## coxph(formula = Surv(coxDataL$TimeMeasure, coxDataL$Event ==
## 1) ~ coxDataL$abs_rltl_change)
##
## n= 304, number of events= 240
##
## coef exp(coef) se(coef) z Pr(>|z|)
## coxDataL$abs_rltl_change 2.7934 16.3372 0.9814 2.846 0.00442 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## exp(coef) exp(-coef) lower .95 upper .95
## coxDataL$abs_rltl_change 16.34 0.06121 2.387 111.8
##
## Concordance= 0.537 (se = 0.023 )
## Likelihood ratio test= 7.49 on 1 df, p=0.006
## Wald test = 8.1 on 1 df, p=0.004
## Score (logrank) test = 8.05 on 1 df, p=0.005
coxFit <- coxph(Surv(coxDataL$TimeMeasure, coxDataL$Event == 1)~coxDataL$rltl_change)
summary(coxFit)
## Call:
## coxph(formula = Surv(coxDataL$TimeMeasure, coxDataL$Event ==
## 1) ~ coxDataL$rltl_change)
##
## n= 304, number of events= 240
##
## coef exp(coef) se(coef) z Pr(>|z|)
## coxDataL$rltl_change -5.065332 0.006312 0.869793 -5.824 5.76e-09 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## exp(coef) exp(-coef) lower .95 upper .95
## coxDataL$rltl_change 0.006312 158.4 0.001148 0.03472
##
## Concordance= 0.572 (se = 0.023 )
## Likelihood ratio test= 26.01 on 1 df, p=3e-07
## Wald test = 33.91 on 1 df, p=6e-09
## Score (logrank) test = 30.05 on 1 df, p=4e-08
#now without first measurement but including milk productivity
#now I will include average milk production, TEL sample number was tested, but removed from the models because it was not statistically associated with productive lifespan
coxDataRL<-subset(coxDataL, coxDataL$amp_305_lactation != "NULL")
#coxDataRL<-merge(coxDataRL, maxSN, by = "recoded_id")
coxFit<-coxph(Surv(coxDataRL$TimeMeasure, coxDataRL$Event == 1)~coxDataRL$average_resid+ as.numeric(paste(coxDataRL$amp_305_lactation)))
summary(coxFit)
## Call:
## coxph(formula = Surv(coxDataRL$TimeMeasure, coxDataRL$Event ==
## 1) ~ coxDataRL$average_resid + as.numeric(paste(coxDataRL$amp_305_lactation)))
##
## n= 253, number of events= 190
##
## coef exp(coef) se(coef)
## coxDataRL$average_resid -4.847e-01 6.159e-01 6.494e-01
## as.numeric(paste(coxDataRL$amp_305_lactation)) -9.853e-05 9.999e-01 2.812e-05
## z Pr(>|z|)
## coxDataRL$average_resid -0.746 0.455445
## as.numeric(paste(coxDataRL$amp_305_lactation)) -3.504 0.000458 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## exp(coef) exp(-coef) lower .95
## coxDataRL$average_resid 0.6159 1.624 0.1725
## as.numeric(paste(coxDataRL$amp_305_lactation)) 0.9999 1.000 0.9998
## upper .95
## coxDataRL$average_resid 2.199
## as.numeric(paste(coxDataRL$amp_305_lactation)) 1.000
##
## Concordance= 0.599 (se = 0.023 )
## Likelihood ratio test= 12.37 on 2 df, p=0.002
## Wald test = 12.93 on 2 df, p=0.002
## Score (logrank) test = 12.92 on 2 df, p=0.002
coxFit<-coxph(Surv(coxDataRL$TimeMeasure, coxDataRL$Event == 1)~coxDataRL$abs_rltl_change+ as.numeric(paste(coxDataRL$amp_305_lactation)))
summary(coxFit)
## Call:
## coxph(formula = Surv(coxDataRL$TimeMeasure, coxDataRL$Event ==
## 1) ~ coxDataRL$abs_rltl_change + as.numeric(paste(coxDataRL$amp_305_lactation)))
##
## n= 253, number of events= 190
##
## coef exp(coef) se(coef)
## coxDataRL$abs_rltl_change 2.403e+00 1.105e+01 1.147e+00
## as.numeric(paste(coxDataRL$amp_305_lactation)) -1.018e-04 9.999e-01 2.818e-05
## z Pr(>|z|)
## coxDataRL$abs_rltl_change 2.095 0.036134 *
## as.numeric(paste(coxDataRL$amp_305_lactation)) -3.610 0.000306 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## exp(coef) exp(-coef) lower .95
## coxDataRL$abs_rltl_change 11.0524 0.09048 1.1680
## as.numeric(paste(coxDataRL$amp_305_lactation)) 0.9999 1.00010 0.9998
## upper .95
## coxDataRL$abs_rltl_change 104.6
## as.numeric(paste(coxDataRL$amp_305_lactation)) 1.0
##
## Concordance= 0.598 (se = 0.023 )
## Likelihood ratio test= 15.95 on 2 df, p=3e-04
## Wald test = 17.02 on 2 df, p=2e-04
## Score (logrank) test = 17.04 on 2 df, p=2e-04
coxFit<-coxph(Surv(coxDataRL$TimeMeasure, coxDataRL$Event == 1)~coxDataRL$rltl_change + as.numeric(paste(coxDataRL$amp_305_lactation)))
summary(coxFit)
## Call:
## coxph(formula = Surv(coxDataRL$TimeMeasure, coxDataRL$Event ==
## 1) ~ coxDataRL$rltl_change + as.numeric(paste(coxDataRL$amp_305_lactation)))
##
## n= 253, number of events= 190
##
## coef exp(coef) se(coef)
## coxDataRL$rltl_change -5.056e+00 6.370e-03 1.315e+00
## as.numeric(paste(coxDataRL$amp_305_lactation)) -9.096e-05 9.999e-01 2.818e-05
## z Pr(>|z|)
## coxDataRL$rltl_change -3.844 0.000121 ***
## as.numeric(paste(coxDataRL$amp_305_lactation)) -3.228 0.001247 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## exp(coef) exp(-coef) lower .95
## coxDataRL$rltl_change 0.00637 157 0.0004836
## as.numeric(paste(coxDataRL$amp_305_lactation)) 0.99991 1 0.9998538
## upper .95
## coxDataRL$rltl_change 0.0839
## as.numeric(paste(coxDataRL$amp_305_lactation)) 1.0000
##
## Concordance= 0.601 (se = 0.022 )
## Likelihood ratio test= 25.3 on 2 df, p=3e-06
## Wald test = 28.32 on 2 df, p=7e-07
## Score (logrank) test = 26.79 on 2 df, p=2e-06
coxFit<-coxph(Surv(coxDataRL$TimeMeasure, coxDataRL$Event == 1)~coxDataRL$rltl_change + coxDataRL$abs_rltl_change+ coxDataRL$average_resid+ as.numeric(paste(coxDataRL$amp_305_lactation)))
summary(coxFit)
See if relationship remains statistically significant when only animals with more than 2 samples are included in the analysis
coxData2<-data.frame(recoded_id=u_more_2$recoded_id, dob = u_more_2$dob, herd_life = u_more_2$herd_life, cull_date = u_more_2$cull_date, average_resid_M2 = u_more_2$average_resid_M2, rltl_change_M2 = u_more_2$rltl_change_M2, abs_rltl_change_M2 = u_more_2$abs_rltl_change_M2, amp_305_lactation = u_more_2$amp_305_lactation, av_rltl_1_res = u_more_2$av_rltl_1_res)
coxData2$CutoffDate<-"01/01/2017"
coxData2$Event<-ifelse(coxData2$cull_date=="NULL", 0, 1)
coxData2$TimeMeasure<-ifelse(coxData2$Event==0, as.Date(coxData2$CutoffDate, "%d/%m/%Y")- as.Date(coxData2$dob, "%d/%m/%Y"), as.numeric(paste(coxData2$herd_life)))
## Warning in ifelse(coxData2$Event == 0, as.Date(coxData2$CutoffDate, "%d/%m/%Y")
## - : NAs introduced by coercion
coxData2$average_resid_3G<-ntile(coxData2$average_resid_M2,3)
coxData2$rltl_change_3G<-ntile(coxData2$rltl_change_M2,3)
coxData2$abs_rltl_change_3G<-ntile(coxData2$abs_rltl_change_M2,3)
# models:
##Average lifetime telomere length
### condinuous variable:
coxFit<-coxph(Surv(coxData2$TimeMeasure, coxData2$Event == 1)~coxData2$average_resid_M2)
summary(coxFit)
## Call:
## coxph(formula = Surv(coxData2$TimeMeasure, coxData2$Event ==
## 1) ~ coxData2$average_resid_M2)
##
## n= 277, number of events= 213
##
## coef exp(coef) se(coef) z Pr(>|z|)
## coxData2$average_resid_M2 -0.5990 0.5494 0.6041 -0.992 0.321
##
## exp(coef) exp(-coef) lower .95 upper .95
## coxData2$average_resid_M2 0.5494 1.82 0.1682 1.795
##
## Concordance= 0.524 (se = 0.022 )
## Likelihood ratio test= 0.99 on 1 df, p=0.3
## Wald test = 0.98 on 1 df, p=0.3
## Score (logrank) test = 0.98 on 1 df, p=0.3
### discrete scale
coxFit<-coxph(Surv(coxData2$TimeMeasure, coxData2$Event == 1)~coxData2$average_resid_3G)
summary(coxFit)
## Call:
## coxph(formula = Surv(coxData2$TimeMeasure, coxData2$Event ==
## 1) ~ coxData2$average_resid_3G)
##
## n= 277, number of events= 213
##
## coef exp(coef) se(coef) z Pr(>|z|)
## coxData2$average_resid_3G -0.10350 0.90168 0.08528 -1.214 0.225
##
## exp(coef) exp(-coef) lower .95 upper .95
## coxData2$average_resid_3G 0.9017 1.109 0.7629 1.066
##
## Concordance= 0.526 (se = 0.021 )
## Likelihood ratio test= 1.47 on 1 df, p=0.2
## Wald test = 1.47 on 1 df, p=0.2
## Score (logrank) test = 1.48 on 1 df, p=0.2
coxFit<-survfit(Surv(coxData2$TimeMeasure, coxData2$Event == 1)~coxData2$average_resid_3G)
#### plot results for discrete scale
survp<- ggsurvplot(coxFit, data=coxData2, pval = TRUE, ggtheme = theme_minimal(), risk.table.y.text.col = T, risk.table.y.text = FALSE, legend.labs=c("Tertile 1 (shortest mean RLTL)", "Tertile 2", "Tertile 3 (longest mean RLTL)"))+theme_survminer(40)
survp
Mean RLTL change
coxFit<-coxph(Surv(coxData2$TimeMeasure, coxData2$Event == 1)~coxData2$rltl_change_M2)
summary(coxFit)
## Call:
## coxph(formula = Surv(coxData2$TimeMeasure, coxData2$Event ==
## 1) ~ coxData2$rltl_change_M2)
##
## n= 277, number of events= 213
##
## coef exp(coef) se(coef) z Pr(>|z|)
## coxData2$rltl_change_M2 -3.46163 0.03138 1.36042 -2.545 0.0109 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## exp(coef) exp(-coef) lower .95 upper .95
## coxData2$rltl_change_M2 0.03138 31.87 0.002181 0.4515
##
## Concordance= 0.544 (se = 0.023 )
## Likelihood ratio test= 6.42 on 1 df, p=0.01
## Wald test = 6.47 on 1 df, p=0.01
## Score (logrank) test = 6.46 on 1 df, p=0.01
### discrete scale
coxFit<-coxph(Surv(coxData2$TimeMeasure, coxData2$Event == 1)~coxData2$rltl_change_3G)
summary(coxFit)
## Call:
## coxph(formula = Surv(coxData2$TimeMeasure, coxData2$Event ==
## 1) ~ coxData2$rltl_change_3G)
##
## n= 277, number of events= 213
##
## coef exp(coef) se(coef) z Pr(>|z|)
## coxData2$rltl_change_3G -0.14184 0.86776 0.08938 -1.587 0.113
##
## exp(coef) exp(-coef) lower .95 upper .95
## coxData2$rltl_change_3G 0.8678 1.152 0.7283 1.034
##
## Concordance= 0.534 (se = 0.021 )
## Likelihood ratio test= 2.52 on 1 df, p=0.1
## Wald test = 2.52 on 1 df, p=0.1
## Score (logrank) test = 2.52 on 1 df, p=0.1
coxFit<-survfit(Surv(coxData2$TimeMeasure, coxData2$Event == 1)~coxData2$rltl_change_3G)
#### plot results for discrete scale
survp<- ggsurvplot(coxFit, data=coxData2, pval = TRUE, ggtheme = theme_minimal(), risk.table.y.text.col = T, risk.table.y.text = FALSE, legend.labs=c("Tertile 1 (most RLTL shortening)", "Tertile 2", "Tertile 3 (least RLTL shortening)"))+theme_survminer(40)
survp
mean absolute RLTL change
coxFit<-coxph(Surv(coxData2$TimeMeasure, coxData2$Event == 1)~coxData2$abs_rltl_change_M2)
summary(coxFit)
## Call:
## coxph(formula = Surv(coxData2$TimeMeasure, coxData2$Event ==
## 1) ~ coxData2$abs_rltl_change_M2)
##
## n= 277, number of events= 213
##
## coef exp(coef) se(coef) z Pr(>|z|)
## coxData2$abs_rltl_change_M2 1.522 4.579 1.159 1.312 0.189
##
## exp(coef) exp(-coef) lower .95 upper .95
## coxData2$abs_rltl_change_M2 4.579 0.2184 0.4719 44.44
##
## Concordance= 0.528 (se = 0.024 )
## Likelihood ratio test= 1.67 on 1 df, p=0.2
## Wald test = 1.72 on 1 df, p=0.2
## Score (logrank) test = 1.72 on 1 df, p=0.2
### discrete scale
coxFit<-coxph(Surv(coxData2$TimeMeasure, coxData2$Event == 1)~coxData2$abs_rltl_change_3G)
summary(coxFit)
## Call:
## coxph(formula = Surv(coxData2$TimeMeasure, coxData2$Event ==
## 1) ~ coxData2$abs_rltl_change_3G)
##
## n= 277, number of events= 213
##
## coef exp(coef) se(coef) z Pr(>|z|)
## coxData2$abs_rltl_change_3G 0.16969 1.18494 0.08624 1.968 0.0491 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## exp(coef) exp(-coef) lower .95 upper .95
## coxData2$abs_rltl_change_3G 1.185 0.8439 1.001 1.403
##
## Concordance= 0.537 (se = 0.021 )
## Likelihood ratio test= 3.88 on 1 df, p=0.05
## Wald test = 3.87 on 1 df, p=0.05
## Score (logrank) test = 3.89 on 1 df, p=0.05
coxFit<-survfit(Surv(coxData2$TimeMeasure, coxData2$Event == 1)~coxData2$abs_rltl_change_3G)
#### plot results for discrete scale
survp<- ggsurvplot(coxFit, data=coxData2, pval = TRUE, ggtheme = theme_minimal(), risk.table.y.text.col = T, risk.table.y.text = FALSE, legend.labs=c("Tertile 1 (least absolute RLTL change)", "Tertile 2", "Tertile 3 (most absolute RLTL change)"))+theme_survminer(40)
survp
Some more figures:
variable_1<-as.numeric(paste(data$sample_interval))
## Warning: NAs introduced by coercion
meanVar_1<-mean(variable_1, na.rm= TRUE)
sdVar<-sd(variable_1, na.rm=TRUE)
samp_int_p<-ggplot(data, aes(x = variable_1)) +
geom_histogram(colour= "black", fill = mycoloursP[7]) + xlab("Sample interval in days") + geom_vline(xintercept= meanVar_1, colour="red")+
theme_classic(20)
samp_int_p
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 305 rows containing non-finite values (stat_bin).
uData<-data[!duplicated(data$recoded_id),]
variable2<-as.factor(paste(uData$birth_year))
yob<-ggplot(uData, aes(x = variable2)) +
geom_bar(colour= "black", fill = mycoloursP[8]) + xlab("Birth year")+ theme_classic(20)
yob
#Average milk production
variable3<-as.numeric(paste(uData$amp_305_lactation))
## Warning: NAs introduced by coercion
meanVar3<-mean(variable3, na.rm= TRUE)
sdVar<-sd(variable3, na.rm=TRUE)
milk_prod<-ggplot(uData, aes(x = variable3)) +
geom_histogram(colour= "black", fill = mycoloursP[9]) + xlab("Average milk production") + geom_vline(xintercept= meanVar3, colour="red")+
theme_classic(20)
milk_prod
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 52 rows containing non-finite values (stat_bin).
grid.arrange(samp_int_p, yob, milk_prod, ncol = 3)
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 305 rows containing non-finite values (stat_bin).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 52 rows containing non-finite values (stat_bin).
grid.arrange(hist2, samp_int_p, milk_prod, prod_lsp_plot, ncol = 2 )
## Warning: Use of `data$residual_rltl_t` is discouraged. Use `residual_rltl_t`
## instead.
## Warning: Use of `data$residual_rltl_t` is discouraged. Use `residual_rltl_t`
## instead.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 305 rows containing non-finite values (stat_bin).
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 52 rows containing non-finite values (stat_bin).
## Warning: Use of `uDeadData$herd_life` is discouraged. Use `herd_life` instead.
## Warning: Use of `uDeadData$herd_life` is discouraged. Use `herd_life` instead.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
# cull reasons
variable<-as.factor(paste(uDeadData$cull_reason))
ggplot(uDeadData, aes(x = variable)) +
geom_bar(colour= "black", fill = mycoloursP[10]) + xlab("Cull reason") +
theme_classic(10)+
theme(axis.text.x = element_text(angle = 90, hjust = 1))
# cull category
variable<-as.factor(paste(uDeadData$cull_category))
variable <- factor(variable, levels = c("Fertility & Reproduction",
"Mastitis" ,
"Lameness",
"Died",
"Poor milk yield",
"Accident",
"Herd management",
"Reason unknown"))
uDeadData$cull_disease <- ifelse(uDeadData$cull_category == "Herd management" |
uDeadData$cull_category == "Accident"|
uDeadData$cull_category == "Reason unknown",
"not exclusively health related", "health related")
cull_p <- ggplot(uDeadData, aes(x = variable, fill = cull_disease)) +
geom_bar(colour= "black") + xlab("Cull reason") +
theme_classic(10)+
theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
scale_fill_manual(values = mycoloursP[8:40])+
labs(fill = "Cull category")
cull_p
# fertility events
newdata <- subset(uData, uData$health_event_fertil_all != "NULL")
variable_f<-as.integer(paste(newdata$health_event_fertil_all))
fert<- ggplot(newdata, aes(x = variable_f)) +
geom_bar(colour= "black", fill = mycoloursP[11]) + xlab("Fertility events")+
theme_classic(20)+
scale_x_continuous(breaks=c(0:12))
#mastitis events
newdata <- subset(uData, uData$health_event_mastitis_all != "NULL")
variable_m<-as.integer(paste(newdata$health_event_mastitis_all))
mast<- ggplot(newdata, aes(x = variable_m)) +
geom_bar(colour= "black", fill = mycoloursP[12]) + xlab("Mastitis events")+
theme_classic(20)+
scale_x_continuous(breaks=c(0:8))
#mast
#lameness events
newdata <- subset(uData, uData$health_event_lame_all != "NULL")
variable_l<-as.integer(paste(newdata$health_event_lame_all))
lame<- ggplot(newdata, aes(x = variable_l)) +
geom_bar(colour= "black", fill = mycoloursP[13]) + xlab("Lameness events")+
theme_classic(20)+
scale_x_continuous(breaks=c(0:11))
grid.arrange(fert, mast, lame, ncol = 3)
#save tables:
tableS1<-as.data.frame(round(coef(summary(init_mod)),3))
tableS2<-as.data.frame(anova(init_mod))
tableS1
## Estimate Std. Error df t value
## (Intercept) -0.126 0.039 1002 -3.256
## redData$age_y 0.022 0.014 1002 1.602
## redData$feed_group2 -0.008 0.012 1002 -0.685
## redData$feed_groupNULL -0.007 0.016 1002 -0.409
## redData$genetic_groupS -0.010 0.011 1002 -0.896
## as.factor(redData$birth_year)2009 -0.014 0.021 1002 -0.694
## as.factor(redData$birth_year)2010 -0.012 0.029 1002 -0.431
## as.factor(redData$birth_year)2011 -0.006 0.039 1002 -0.164
## as.factor(redData$birth_year)2012 -0.022 0.055 1002 -0.396
## as.factor(redData$birth_year)2013 -0.147 0.111 1002 -1.316
## as.factor(redData$birth_year)2014 -0.242 0.193 1002 -1.255
## as.factor(redData$sample_year)2011 0.042 0.026 1002 1.573
## as.factor(redData$sample_year)2012 0.063 0.033 1002 1.895
## as.factor(redData$sample_year)2013 0.087 0.045 1002 1.954
## as.factor(redData$sample_year)2014 0.064 0.060 1002 1.052
## as.numeric(paste(redData$sample_interval)) 0.000 0.000 1002 -0.049
## redData$health_event_2week 0.018 0.024 1002 0.721
## Pr(>|t|)
## (Intercept) 0.001
## redData$age_y 0.110
## redData$feed_group2 0.493
## redData$feed_groupNULL 0.683
## redData$genetic_groupS 0.371
## as.factor(redData$birth_year)2009 0.488
## as.factor(redData$birth_year)2010 0.666
## as.factor(redData$birth_year)2011 0.870
## as.factor(redData$birth_year)2012 0.692
## as.factor(redData$birth_year)2013 0.189
## as.factor(redData$birth_year)2014 0.210
## as.factor(redData$sample_year)2011 0.116
## as.factor(redData$sample_year)2012 0.058
## as.factor(redData$sample_year)2013 0.051
## as.factor(redData$sample_year)2014 0.293
## as.numeric(paste(redData$sample_interval)) 0.961
## redData$health_event_2week 0.471
tableS2
## Sum Sq Mean Sq NumDF
## redData$age_y 7.576244e-02 7.576244e-02 1
## redData$feed_group 1.465413e-02 7.327063e-03 2
## redData$genetic_group 2.369438e-02 2.369438e-02 1
## as.factor(redData$birth_year) 1.287738e-01 2.146230e-02 6
## as.factor(redData$sample_year) 3.123400e-01 7.808501e-02 4
## as.numeric(paste(redData$sample_interval)) 7.208751e-05 7.208751e-05 1
## redData$health_event_2week 1.535081e-02 1.535081e-02 1
## DenDF F value Pr(>F)
## redData$age_y 1002 2.565692271 0.10951993
## redData$feed_group 1002 0.248130725 0.78030587
## redData$genetic_group 1002 0.802409443 0.37058910
## as.factor(redData$birth_year) 1002 0.726819901 0.62806340
## as.factor(redData$sample_year) 1002 2.644345994 0.03235318
## as.numeric(paste(redData$sample_interval)) 1002 0.002441241 0.96060327
## redData$health_event_2week 1002 0.519854551 0.47107192
#save tables:
tableS3<-as.data.frame(round(coef(summary(late_mod)),3))
tableS4<-as.data.frame(anova(late_mod))
tableS3
## Estimate Std. Error df t value
## (Intercept) -0.126 0.039 1002 -3.256
## long_dat$age_y 0.022 0.014 1002 1.602
## long_dat$feed_group2 -0.008 0.012 1002 -0.685
## long_dat$feed_groupNULL -0.007 0.016 1002 -0.409
## long_dat$genetic_groupS -0.010 0.011 1002 -0.896
## as.factor(long_dat$birth_year)2009 -0.014 0.021 1002 -0.694
## as.factor(long_dat$birth_year)2010 -0.012 0.029 1002 -0.431
## as.factor(long_dat$birth_year)2011 -0.006 0.039 1002 -0.164
## as.factor(long_dat$birth_year)2012 -0.022 0.055 1002 -0.396
## as.factor(long_dat$birth_year)2013 -0.147 0.111 1002 -1.316
## as.factor(long_dat$birth_year)2014 -0.242 0.193 1002 -1.255
## as.factor(long_dat$sample_year)2011 0.042 0.026 1002 1.573
## as.factor(long_dat$sample_year)2012 0.063 0.033 1002 1.895
## as.factor(long_dat$sample_year)2013 0.087 0.045 1002 1.954
## as.factor(long_dat$sample_year)2014 0.064 0.060 1002 1.052
## as.numeric(paste(long_dat$sample_interval)) 0.000 0.000 1002 -0.049
## long_dat$health_event_2week 0.018 0.024 1002 0.721
## Pr(>|t|)
## (Intercept) 0.001
## long_dat$age_y 0.110
## long_dat$feed_group2 0.493
## long_dat$feed_groupNULL 0.683
## long_dat$genetic_groupS 0.371
## as.factor(long_dat$birth_year)2009 0.488
## as.factor(long_dat$birth_year)2010 0.666
## as.factor(long_dat$birth_year)2011 0.870
## as.factor(long_dat$birth_year)2012 0.692
## as.factor(long_dat$birth_year)2013 0.189
## as.factor(long_dat$birth_year)2014 0.210
## as.factor(long_dat$sample_year)2011 0.116
## as.factor(long_dat$sample_year)2012 0.058
## as.factor(long_dat$sample_year)2013 0.051
## as.factor(long_dat$sample_year)2014 0.293
## as.numeric(paste(long_dat$sample_interval)) 0.961
## long_dat$health_event_2week 0.471
tableS4
## Sum Sq Mean Sq NumDF
## long_dat$age_y 7.576244e-02 7.576244e-02 1
## long_dat$feed_group 1.465413e-02 7.327063e-03 2
## long_dat$genetic_group 2.369438e-02 2.369438e-02 1
## as.factor(long_dat$birth_year) 1.287738e-01 2.146230e-02 6
## as.factor(long_dat$sample_year) 3.123400e-01 7.808501e-02 4
## as.numeric(paste(long_dat$sample_interval)) 7.208751e-05 7.208751e-05 1
## long_dat$health_event_2week 1.535081e-02 1.535081e-02 1
## DenDF F value Pr(>F)
## long_dat$age_y 1002 2.565692271 0.10951993
## long_dat$feed_group 1002 0.248130725 0.78030587
## long_dat$genetic_group 1002 0.802409443 0.37058910
## as.factor(long_dat$birth_year) 1002 0.726819901 0.62806340
## as.factor(long_dat$sample_year) 1002 2.644345994 0.03235318
## as.numeric(paste(long_dat$sample_interval)) 1002 0.002441241 0.96060327
## long_dat$health_event_2week 1002 0.519854551 0.47107192
#save tables:
tableS5<-as.data.frame(round(coef(summary(red_mod)),3))
tableS6<-as.data.frame(anova(red_mod))
tableS5
## Estimate Std. Error df t value
## (Intercept) -0.142 0.028 1009 -5.029
## redData$age_y 0.026 0.006 1009 4.266
## redData$feed_group2 -0.010 0.012 1009 -0.867
## redData$feed_groupNULL -0.015 0.015 1009 -0.969
## redData$genetic_groupS -0.013 0.011 1009 -1.113
## as.factor(redData$sample_year)2011 0.040 0.023 1009 1.744
## as.factor(redData$sample_year)2012 0.061 0.022 1009 2.735
## as.factor(redData$sample_year)2013 0.081 0.024 1009 3.438
## as.factor(redData$sample_year)2014 0.050 0.027 1009 1.834
## as.numeric(paste(redData$sample_interval)) 0.000 0.000 1009 0.198
## Pr(>|t|)
## (Intercept) 0.000
## redData$age_y 0.000
## redData$feed_group2 0.386
## redData$feed_groupNULL 0.333
## redData$genetic_groupS 0.266
## as.factor(redData$sample_year)2011 0.082
## as.factor(redData$sample_year)2012 0.006
## as.factor(redData$sample_year)2013 0.001
## as.factor(redData$sample_year)2014 0.067
## as.numeric(paste(redData$sample_interval)) 0.843
tableS6
## Sum Sq Mean Sq NumDF DenDF
## redData$age_y 0.536302630 0.536302630 1 1009
## redData$feed_group 0.036496026 0.018248013 2 1009
## redData$genetic_group 0.036502536 0.036502536 1 1009
## as.factor(redData$sample_year) 0.452100679 0.113025170 4 1009
## as.numeric(paste(redData$sample_interval)) 0.001149941 0.001149941 1 1009
## F value Pr(>F)
## redData$age_y 18.20011295 2.175661e-05
## redData$feed_group 0.61926957 5.385420e-01
## redData$genetic_group 1.23876005 2.659752e-01
## as.factor(redData$sample_year) 3.83565312 4.224364e-03
## as.numeric(paste(redData$sample_interval)) 0.03902473 8.434395e-01
#save tables:
tableS7<-as.data.frame(round(coef(summary(red_mod_fac)),3))
tableS8<-as.data.frame(anova(red_mod_fac))
tableS7
## Estimate Std. Error df t value
## (Intercept) -0.051 0.032 1009 -1.590
## redData$AgeGroupyoung -0.073 0.019 1009 -3.880
## redData$feed_group2 -0.006 0.012 1009 -0.485
## redData$feed_groupNULL -0.018 0.015 1009 -1.157
## redData$genetic_groupS -0.016 0.011 1009 -1.383
## as.factor(redData$sample_year)2011 0.037 0.023 1009 1.611
## as.factor(redData$sample_year)2012 0.062 0.022 1009 2.765
## as.factor(redData$sample_year)2013 0.095 0.023 1009 4.226
## as.factor(redData$sample_year)2014 0.094 0.023 1009 4.100
## as.numeric(paste(redData$sample_interval)) 0.000 0.000 1009 -1.259
## Pr(>|t|)
## (Intercept) 0.112
## redData$AgeGroupyoung 0.000
## redData$feed_group2 0.628
## redData$feed_groupNULL 0.247
## redData$genetic_groupS 0.167
## as.factor(redData$sample_year)2011 0.107
## as.factor(redData$sample_year)2012 0.006
## as.factor(redData$sample_year)2013 0.000
## as.factor(redData$sample_year)2014 0.000
## as.numeric(paste(redData$sample_interval)) 0.208
tableS8
## Sum Sq Mean Sq NumDF DenDF
## redData$AgeGroup 0.44502793 0.44502793 1 1009
## redData$feed_group 0.03964620 0.01982310 2 1009
## redData$genetic_group 0.05655803 0.05655803 1 1009
## as.factor(redData$sample_year) 0.80474650 0.20118663 4 1009
## as.numeric(paste(redData$sample_interval)) 0.04684187 0.04684187 1 1009
## F value Pr(>F)
## redData$AgeGroup 15.0563682 1.111176e-04
## redData$feed_group 0.6706633 5.115971e-01
## redData$genetic_group 1.9134944 1.668816e-01
## as.factor(redData$sample_year) 6.8066288 2.090169e-05
## as.numeric(paste(redData$sample_interval)) 1.5847735 2.083656e-01
## Estimate Std. Error df t value
## (Intercept) -0.143 0.035 906 -4.057
## PData$age_y 0.021 0.007 906 3.078
## PData$feed_group2 -0.006 0.013 906 -0.429
## PData$feed_groupNULL 0.009 0.024 906 0.379
## PData$genetic_groupS -0.011 0.012 906 -0.926
## as.factor(PData$sample_year)2011 0.038 0.024 906 1.597
## as.factor(PData$sample_year)2012 0.060 0.023 906 2.600
## as.factor(PData$sample_year)2013 0.086 0.025 906 3.417
## as.factor(PData$sample_year)2014 0.064 0.030 906 2.131
## as.numeric(paste(PData$sample_interval)) 0.000 0.000 906 -0.461
## rescaled_prod 0.003 0.003 906 0.963
## Pr(>|t|)
## (Intercept) 0.000
## PData$age_y 0.002
## PData$feed_group2 0.668
## PData$feed_groupNULL 0.704
## PData$genetic_groupS 0.355
## as.factor(PData$sample_year)2011 0.111
## as.factor(PData$sample_year)2012 0.009
## as.factor(PData$sample_year)2013 0.001
## as.factor(PData$sample_year)2014 0.033
## as.numeric(paste(PData$sample_interval)) 0.645
## rescaled_prod 0.336
## Sum Sq Mean Sq NumDF DenDF
## PData$age_y 0.277574210 0.277574210 1 906
## PData$feed_group 0.017506358 0.008753179 2 906
## PData$genetic_group 0.025108197 0.025108197 1 906
## as.factor(PData$sample_year) 0.405141736 0.101285434 4 906
## as.numeric(paste(PData$sample_interval)) 0.006225897 0.006225897 1 906
## rescaled_prod 0.027188984 0.027188984 1 906
## F value Pr(>F)
## PData$age_y 9.4711963 0.002150018
## PData$feed_group 0.2986699 0.741877212
## PData$genetic_group 0.8567246 0.354903384
## as.factor(PData$sample_year) 3.4559919 0.008191816
## as.numeric(paste(PData$sample_interval)) 0.2124358 0.644975545
## rescaled_prod 0.9277238 0.335712088
Complete dataset:
date_table<- table(data$sample_date)
date_table <- setNames(data.frame(table(data$sample_date)),c("Date","Count"))
date_table$Date<-as.Date(date_table$Date, "%d/%m/%Y")
date_table$Count<-as.numeric(paste(date_table$Count))
ggplot(date_table, aes( x = Date, y= Count)) + geom_line(colour= mycoloursP[19]) + geom_point(colour = mycoloursP[18]) +theme_bw() +
scale_x_date(date_labels="%b", date_breaks="month", expand=c(0,0)) +
facet_grid(~ year(Date), space="free_x", scales="free_x", switch="x") +
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))+
theme(strip.placement = "outside",
strip.background = element_rect(fill=NA,colour="grey50"),
panel.spacing=unit(0,"cm"))
lame_mod<- lm(uDeadData$abs_rltl_change ~ as.numeric(paste(uDeadData$health_event_lame_all)))
## Warning in eval(predvars, data, env): NAs introduced by coercion
summary(lame_mod)
##
## Call:
## lm(formula = uDeadData$abs_rltl_change ~ as.numeric(paste(uDeadData$health_event_lame_all)))
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.13511 -0.04737 -0.00685 0.03400 0.48221
##
## Coefficients:
## Estimate Std. Error t value
## (Intercept) 0.158190 0.008408 18.82
## as.numeric(paste(uDeadData$health_event_lame_all)) -0.004037 0.003082 -1.31
## Pr(>|t|)
## (Intercept) <2e-16 ***
## as.numeric(paste(uDeadData$health_event_lame_all)) 0.192
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.07719 on 140 degrees of freedom
## (99 observations deleted due to missingness)
## Multiple R-squared: 0.01211, Adjusted R-squared: 0.005051
## F-statistic: 1.716 on 1 and 140 DF, p-value: 0.1924
lame_mod_RLTL<- lm(uDeadData$average_resid ~ as.numeric(paste(uDeadData$health_event_lame_all)))
## Warning in eval(predvars, data, env): NAs introduced by coercion
summary(lame_mod_RLTL)
##
## Call:
## lm(formula = uDeadData$average_resid ~ as.numeric(paste(uDeadData$health_event_lame_all)))
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.32760 -0.08116 -0.01310 0.08243 0.42704
##
## Coefficients:
## Estimate Std. Error
## (Intercept) -0.0022188 0.0127342
## as.numeric(paste(uDeadData$health_event_lame_all)) 0.0003725 0.0046674
## t value Pr(>|t|)
## (Intercept) -0.174 0.862
## as.numeric(paste(uDeadData$health_event_lame_all)) 0.080 0.937
##
## Residual standard error: 0.1169 on 140 degrees of freedom
## (99 observations deleted due to missingness)
## Multiple R-squared: 4.549e-05, Adjusted R-squared: -0.007097
## F-statistic: 0.006368 on 1 and 140 DF, p-value: 0.9365
lame_mod_RLTLch<- lm(uDeadData$rltl_change ~ as.numeric(paste(uDeadData$health_event_lame_all)))
## Warning in eval(predvars, data, env): NAs introduced by coercion
summary(lame_mod_RLTLch)
##
## Call:
## lm(formula = uDeadData$rltl_change ~ as.numeric(paste(uDeadData$health_event_lame_all)))
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.59091 -0.03319 0.00155 0.04026 0.17965
##
## Coefficients:
## Estimate Std. Error t value
## (Intercept) -0.049485 0.008693 -5.693
## as.numeric(paste(uDeadData$health_event_lame_all)) 0.005289 0.003186 1.660
## Pr(>|t|)
## (Intercept) 7.06e-08 ***
## as.numeric(paste(uDeadData$health_event_lame_all)) 0.0992 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.0798 on 140 degrees of freedom
## (99 observations deleted due to missingness)
## Multiple R-squared: 0.0193, Adjusted R-squared: 0.0123
## F-statistic: 2.756 on 1 and 140 DF, p-value: 0.09916
mast_mod<- lm(uDeadData$abs_rltl_change ~ as.numeric(paste(uDeadData$health_event_mastitis_all)))
## Warning in eval(predvars, data, env): NAs introduced by coercion
summary(mast_mod)
##
## Call:
## lm(formula = uDeadData$abs_rltl_change ~ as.numeric(paste(uDeadData$health_event_mastitis_all)))
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.12631 -0.04094 -0.01005 0.03472 0.49101
##
## Coefficients:
## Estimate Std. Error
## (Intercept) 0.156041 0.007458
## as.numeric(paste(uDeadData$health_event_mastitis_all)) -0.006652 0.005047
## t value Pr(>|t|)
## (Intercept) 20.924 <2e-16 ***
## as.numeric(paste(uDeadData$health_event_mastitis_all)) -1.318 0.19
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.07718 on 140 degrees of freedom
## (99 observations deleted due to missingness)
## Multiple R-squared: 0.01225, Adjusted R-squared: 0.0052
## F-statistic: 1.737 on 1 and 140 DF, p-value: 0.1897
mast_mod_RLTL<- lm(uDeadData$average_resid ~ as.numeric(paste(uDeadData$health_event_mastitis_all)))
## Warning in eval(predvars, data, env): NAs introduced by coercion
summary(mast_mod_RLTL)
##
## Call:
## lm(formula = uDeadData$average_resid ~ as.numeric(paste(uDeadData$health_event_mastitis_all)))
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.33261 -0.07890 -0.01594 0.07884 0.43394
##
## Coefficients:
## Estimate Std. Error
## (Intercept) 0.002792 0.011272
## as.numeric(paste(uDeadData$health_event_mastitis_all)) -0.005956 0.007629
## t value Pr(>|t|)
## (Intercept) 0.248 0.805
## as.numeric(paste(uDeadData$health_event_mastitis_all)) -0.781 0.436
##
## Residual standard error: 0.1167 on 140 degrees of freedom
## (99 observations deleted due to missingness)
## Multiple R-squared: 0.004336, Adjusted R-squared: -0.002776
## F-statistic: 0.6096 on 1 and 140 DF, p-value: 0.4362
mast_mod_RLTLch<- lm(uDeadData$rltl_change ~ as.numeric(paste(uDeadData$health_event_mastitis_all)))
## Warning in eval(predvars, data, env): NAs introduced by coercion
summary(mast_mod_RLTLch)
##
## Call:
## lm(formula = uDeadData$rltl_change ~ as.numeric(paste(uDeadData$health_event_mastitis_all)))
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.60018 -0.03643 0.01187 0.04075 0.17038
##
## Coefficients:
## Estimate Std. Error
## (Intercept) -0.0404640 0.0077865
## as.numeric(paste(uDeadData$health_event_mastitis_all)) 0.0002443 0.0052699
## t value Pr(>|t|)
## (Intercept) -5.197 7.03e-07 ***
## as.numeric(paste(uDeadData$health_event_mastitis_all)) 0.046 0.963
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.08059 on 140 degrees of freedom
## (99 observations deleted due to missingness)
## Multiple R-squared: 1.535e-05, Adjusted R-squared: -0.007127
## F-statistic: 0.00215 on 1 and 140 DF, p-value: 0.9631
uDeadData$comb_mast_lame <- as.numeric(paste(uDeadData$health_event_mastitis_all)) +
as.numeric(paste(uDeadData$health_event_lame_all))
## Warning: NAs introduced by coercion
## Warning: NAs introduced by coercion
comb_mod<- lm(uDeadData$abs_rltl_change ~ uDeadData$comb_mast_lame)
summary(comb_mod)
##
## Call:
## lm(formula = uDeadData$abs_rltl_change ~ uDeadData$comb_mast_lame)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.13455 -0.04512 -0.00712 0.03201 0.48277
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.162018 0.008961 18.081 <2e-16 ***
## uDeadData$comb_mast_lame -0.004389 0.002517 -1.743 0.0835 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.07683 on 140 degrees of freedom
## (99 observations deleted due to missingness)
## Multiple R-squared: 0.02125, Adjusted R-squared: 0.01426
## F-statistic: 3.04 on 1 and 140 DF, p-value: 0.08345
comb_mod_RLTL<- lm(uDeadData$average_resid ~ uDeadData$comb_mast_lame)
summary(comb_mod_RLTL)
##
## Call:
## lm(formula = uDeadData$average_resid ~ uDeadData$comb_mast_lame)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.33132 -0.07869 -0.01396 0.08067 0.42581
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.001505 0.013630 0.110 0.912
## uDeadData$comb_mast_lame -0.001245 0.003829 -0.325 0.746
##
## Residual standard error: 0.1169 on 140 degrees of freedom
## (99 observations deleted due to missingness)
## Multiple R-squared: 0.0007539, Adjusted R-squared: -0.006384
## F-statistic: 0.1056 on 1 and 140 DF, p-value: 0.7457
comb_mod_RLTLch<- lm(uDeadData$rltl_change ~ uDeadData$comb_mast_lame)
summary(comb_mod_RLTLch)
##
## Call:
## lm(formula = uDeadData$rltl_change ~ uDeadData$comb_mast_lame)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.59478 -0.03429 0.00536 0.04068 0.17578
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.049243 0.009335 -5.275 4.93e-07 ***
## uDeadData$comb_mast_lame 0.003624 0.002623 1.382 0.169
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.08004 on 140 degrees of freedom
## (99 observations deleted due to missingness)
## Multiple R-squared: 0.01345, Adjusted R-squared: 0.006407
## F-statistic: 1.909 on 1 and 140 DF, p-value: 0.1693
Less telomere attrition correlates with more fertility events. While mastatis and lameness events are negative, fertility events include positive outcomes such as an animal seen to show signs of fertility and having a calf.
fer_mod<- lm(uDeadData$abs_rltl_change ~ as.numeric(paste(uDeadData$health_event_fertil_all)))
## Warning in eval(predvars, data, env): NAs introduced by coercion
summary(fer_mod)
##
## Call:
## lm(formula = uDeadData$abs_rltl_change ~ as.numeric(paste(uDeadData$health_event_fertil_all)))
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.14181 -0.04230 -0.00784 0.03398 0.47906
##
## Coefficients:
## Estimate Std. Error
## (Intercept) 0.164882 0.011509
## as.numeric(paste(uDeadData$health_event_fertil_all)) -0.003547 0.002462
## t value Pr(>|t|)
## (Intercept) 14.326 <2e-16 ***
## as.numeric(paste(uDeadData$health_event_fertil_all)) -1.441 0.152
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.07709 on 140 degrees of freedom
## (99 observations deleted due to missingness)
## Multiple R-squared: 0.01461, Adjusted R-squared: 0.007569
## F-statistic: 2.075 on 1 and 140 DF, p-value: 0.1519
fer_mod_RLTL<- lm(uDeadData$average_resid ~ as.numeric(paste(uDeadData$health_event_fertil_all)))
## Warning in eval(predvars, data, env): NAs introduced by coercion
summary(fer_mod_RLTL)
##
## Call:
## lm(formula = uDeadData$average_resid ~ as.numeric(paste(uDeadData$health_event_fertil_all)))
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.34245 -0.08476 -0.01527 0.07784 0.40723
##
## Coefficients:
## Estimate Std. Error
## (Intercept) 0.017591 0.017343
## as.numeric(paste(uDeadData$health_event_fertil_all)) -0.004956 0.003710
## t value Pr(>|t|)
## (Intercept) 1.014 0.312
## as.numeric(paste(uDeadData$health_event_fertil_all)) -1.336 0.184
##
## Residual standard error: 0.1162 on 140 degrees of freedom
## (99 observations deleted due to missingness)
## Multiple R-squared: 0.01259, Adjusted R-squared: 0.005534
## F-statistic: 1.785 on 1 and 140 DF, p-value: 0.1837
fer_mod_RLTLch<- lm(uDeadData$rltl_change ~ as.numeric(paste(uDeadData$health_event_fertil_all)))
## Warning in eval(predvars, data, env): NAs introduced by coercion
summary(fer_mod_RLTLch)
##
## Call:
## lm(formula = uDeadData$rltl_change ~ as.numeric(paste(uDeadData$health_event_fertil_all)))
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.58352 -0.03138 0.00080 0.04107 0.18703
##
## Coefficients:
## Estimate Std. Error
## (Intercept) -0.062661 0.011811
## as.numeric(paste(uDeadData$health_event_fertil_all)) 0.005788 0.002527
## t value Pr(>|t|)
## (Intercept) -5.305 4.3e-07 ***
## as.numeric(paste(uDeadData$health_event_fertil_all)) 2.291 0.0235 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.07912 on 140 degrees of freedom
## (99 observations deleted due to missingness)
## Multiple R-squared: 0.03612, Adjusted R-squared: 0.02924
## F-statistic: 5.247 on 1 and 140 DF, p-value: 0.02348
ggplot(uDeadData, aes(x= as.numeric(paste(uDeadData$health_event_fertil_all)), y= rltl_change)) + geom_point()
## Warning in FUN(X[[i]], ...): NAs introduced by coercion
## Warning in FUN(X[[i]], ...): NAs introduced by coercion
## Warning: Use of `uDeadData$health_event_fertil_all` is discouraged. Use
## `health_event_fertil_all` instead.
## Warning: Removed 99 rows containing missing values (geom_point).
# Fig. Initial change data
in_df<-data.frame(recoded_id = init_change_dat$recoded_id, RLTL = init_change_dat$RLTL0, age= 0, year= init_change_dat$sample_year0)
in_df2<-data.frame(recoded_id = init_change_dat$recoded_id, RLTL = init_change_dat$RLTL1, age= 1, year= init_change_dat$sample_year)
init_df<-rbind(in_df, in_df2)
in_plot1<-ggplot(data = init_df, aes(x = as.factor(init_df$age), y = RLTL, group = recoded_id, colour = recoded_id))+geom_point()+ geom_line()+
xlab("Age in years") + ylab("RLTL residuals") + theme_classic(20)+ theme(legend.position = "none")
in_plot2<-ggplot(data = init_df, aes(x = as.factor(init_df$year), y = RLTL, group = recoded_id, colour = recoded_id))+geom_point()+ geom_line()+
xlab("Age in years") + ylab("RLTL residuals") + theme_classic(20)+ theme(legend.position = "none")
grid.arrange(in_plot1, in_plot2, ncol = 2)
## Warning: Use of `init_df$age` is discouraged. Use `age` instead.
## Warning: Use of `init_df$age` is discouraged. Use `age` instead.
## Warning: Use of `init_df$year` is discouraged. Use `year` instead.
## Warning: Use of `init_df$year` is discouraged. Use `year` instead.
weath_plot_dat<-read.csv(here::here("data", "eskdalemuirdata_red_plot.csv"))
weath_plot_dat<-subset(weath_plot_dat, weath_plot_dat$yyyy > 2005)
weath_plot_dat<-subset(weath_plot_dat, weath_plot_dat$yyyy < 2016)
weath_plot_dat$mm <- ifelse(weath_plot_dat$mm < 10, paste0("0", weath_plot_dat$mm), weath_plot_dat$mm)
weath_plot_dat$date<-paste(weath_plot_dat$yyyy, weath_plot_dat$mm, "01", sep = "-")
weath_plot_dat$date<- as.Date(weath_plot_dat$date)
weath_plot_dat$tmax_degC<-as.numeric(paste(weath_plot_dat$tmax_degC))
w1<-ggplot(weath_plot_dat, aes( x = date, y= tmax_degC)) + geom_line(colour= mycoloursP[20], size = 2) + geom_point(colour = mycoloursP[21], size = 2) +theme_bw(20) +
ylab("Maximum temperature °C")+
xlab("Measurement time point")+
scale_x_date(date_labels="%b", date_breaks="month", expand=c(0,0)) +
facet_grid(~ year(date), space="free_x", scales="free_x", switch="x") +
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))+
theme(strip.placement = "outside",
strip.background = element_rect(fill=NA,colour="grey50"),
panel.spacing=unit(0.4,"cm"))
weath_plot_dat$tmin_degC<-as.numeric(paste(weath_plot_dat$tmin_degC))
w2<-ggplot(weath_plot_dat, aes( x = date, y= tmin_degC)) + geom_line(colour= mycoloursP[22], size = 2) + geom_point(colour = mycoloursP[23], size = 2) +theme_bw(20) +
ylab("Minimum temperature °C")+
xlab("Measurement time point")+
scale_x_date(date_labels="%b", date_breaks="month", expand=c(0,0)) +
facet_grid(~ year(date), space="free_x", scales="free_x", switch="x") +
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))+
theme(strip.placement = "outside",
strip.background = element_rect(fill=NA,colour="grey50"),
panel.spacing=unit(0.4,"cm"))
weath_plot_dat$af_days<-as.numeric(paste(weath_plot_dat$af_days))
w3<-ggplot(weath_plot_dat, aes( x = date, y= af_days)) + geom_line(colour= mycoloursP[24], size = 2) + geom_point(colour = mycoloursP[25], size = 2) +theme_bw(20) +
ylab("Air frost days")+
xlab("Measurement time point")+
scale_x_date(date_labels="%b", date_breaks="month", expand=c(0,0)) +
facet_grid(~ year(date), space="free_x", scales="free_x", switch="x") +
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))+
theme(strip.placement = "outside",
strip.background = element_rect(fill=NA,colour="grey50"),
panel.spacing=unit(0.4,"cm"))
weath_plot_dat$sun_hours_c<-as.numeric(paste(substr(weath_plot_dat$sun_hours,1,nchar(weath_plot_dat$sun_hours)-1)))
w4<-ggplot(weath_plot_dat, aes( x = date, y= sun_hours_c)) + geom_line(colour= mycoloursP[26], size = 2) + geom_point(colour = mycoloursP[27], size = 2) +theme_bw(20) +
ylab("Sun hours per")+
xlab("Measurement time point")+
scale_x_date(date_labels="%b", date_breaks="month", expand=c(0,0)) +
facet_grid(~ year(date), space="free_x", scales="free_x", switch="x") +
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))+
theme(strip.placement = "outside",
strip.background = element_rect(fill=NA,colour="grey50"),
panel.spacing=unit(0.4,"cm"))
weath_plot_dat$rain_mm<-as.numeric(paste(weath_plot_dat$rain_mm))
w5<-ggplot(weath_plot_dat, aes( x = date, y= rain_mm)) + geom_line(colour= mycoloursP[28], size = 2) + geom_point(colour = mycoloursP[29], size = 2) +theme_bw(20) +
ylab("Rain in mm")+
xlab("Measurement time point")+
scale_x_date(date_labels="%b", date_breaks="month", expand=c(0,0)) +
facet_grid(~ year(date), space="free_x", scales="free_x", switch="x") +
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))+
theme(strip.placement = "outside",
strip.background = element_rect(fill=NA,colour="grey50"),
panel.spacing=unit(0.4,"cm"))
grid.arrange(w1, w2, w3, w4, w5, ncol = 1)
sessionInfo()
## R version 4.0.2 (2020-06-22)
## Platform: x86_64-apple-darwin17.0 (64-bit)
## Running under: macOS Catalina 10.15.6
##
## Matrix products: default
## BLAS: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
##
## locale:
## [1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8
##
## attached base packages:
## [1] grid stats graphics grDevices utils datasets methods
## [8] base
##
## other attached packages:
## [1] here_1.0.1 ggsci_2.9 survminer_0.4.9 ggpubr_0.4.0
## [5] survival_3.2-10 dplyr_1.0.5 plyr_1.8.6 ggthemes_4.2.4
## [9] stringr_1.4.0 data.table_1.14.0 mgcv_1.8-34 gridExtra_2.3
## [13] lmerTest_3.1-3 lme4_1.1-26 Matrix_1.3-2 nlme_3.1-152
## [17] ggplot2_3.3.3
##
## loaded via a namespace (and not attached):
## [1] rprojroot_2.0.2 numDeriv_2016.8-1.1 tools_4.0.2
## [4] backports_1.2.1 bslib_0.2.4 utf8_1.2.1
## [7] R6_2.5.0 DBI_1.1.1 colorspace_2.0-0
## [10] withr_2.4.1 tidyselect_1.1.0 curl_4.3
## [13] compiler_4.0.2 labeling_0.4.2 sass_0.3.1
## [16] scales_1.1.1 survMisc_0.5.5 digest_0.6.27
## [19] foreign_0.8-81 minqa_1.2.4 rmarkdown_2.7
## [22] rio_0.5.26 pkgconfig_2.0.3 htmltools_0.5.1.1
## [25] highr_0.8 rlang_0.4.10 readxl_1.3.1
## [28] jquerylib_0.1.3 generics_0.1.0 farver_2.1.0
## [31] zoo_1.8-9 jsonlite_1.7.2 zip_2.1.1
## [34] car_3.0-10 magrittr_2.0.1 Rcpp_1.0.6
## [37] munsell_0.5.0 fansi_0.4.2 abind_1.4-5
## [40] lifecycle_1.0.0 stringi_1.5.3 yaml_2.2.1
## [43] carData_3.0-4 MASS_7.3-53.1 forcats_0.5.1
## [46] crayon_1.4.1 lattice_0.20-41 haven_2.3.1
## [49] splines_4.0.2 hms_1.0.0 knitr_1.31
## [52] pillar_1.5.1 boot_1.3-27 ggsignif_0.6.1
## [55] glue_1.4.2 evaluate_0.14 vctrs_0.3.6
## [58] nloptr_1.2.2.2 cellranger_1.1.0 gtable_0.3.0
## [61] purrr_0.3.4 tidyr_1.1.3 km.ci_0.5-2
## [64] assertthat_0.2.1 xfun_0.22 openxlsx_4.2.3
## [67] xtable_1.8-4 broom_0.7.5 rstatix_0.7.0
## [70] tibble_3.1.0 KMsurv_0.1-5 statmod_1.4.35
## [73] ellipsis_0.3.1